0

由于某种原因,即使认为它运行没有错误,代码也没有更新数据库,有什么想法吗?!这是一个动态包含,所以我已经有了包含 login_check 函数的 functions.php 和其他一些函数。

<?php 
if(login_check($mysqli) == true) {

// The hashed password from the form
$password1 = $_POST['p'];

// Create a random salt
$random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
// Create salted password (Careful not to over season)
$password1 = hash('sha512', $password1.$random_salt);

$errors=0;
$error="The following errors occured while processing your form input.<ul>";

if($nombre1=="" || $apellido1=="" || $username1=="" || $email1=="" || $password1=="" || $telefono1==""){
$errors=1;

$error.="<li>You did not fill one or more required fields, go back and try again.";
}

if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email1)){
$error.="<li>Invalid email address.";
$errors=1;
}

if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));


// coneccion al servidor de bases de datos
$mysqli = new mysqli("xxx","xxxxx","xxxx","xxxxx") or die ("Could not connect :" . mysql_error());


// ejecucion del query

if ($insert_stmt = $mysqli->prepare("UPDATE members SET (nombre, apellido, username, email, password, salt, telefono) VALUES (?, ?, ?, ?, ?, ?, ?) WHERE `cedula` = '$cedula'")) {    
   $insert_stmt->bind_param('sssssss', $nombre1, $apellido1, $username1, $email1, $password1, $random_salt, $telefono1); 
// Execute the prepared query.
   $insert_stmt->execute();
}
?>

//html here

<?
}
}
?>
4

1 回答 1

0

如果我对

像这样的sql更新 -

update yourTable set nombre=?,apellido=?,username=? where cedula='$cedula';  

像这样插入sql -

insert into yourTable(nombre,username,apellido) values(?,?,?);  

用 sql sysntax 试试这个。谢谢

于 2013-07-31T02:50:22.123 回答