嘿,所以我制作了一个注册页面,一切正常,但是mysqli_fetch_array没有从数据库获取信息
$query = "INSERT INTO `users` VALUES('$fname','$lname','$email','".md5(md5($email).$password)."','$company_name','','','','','') ";
$suq = mysqli_query($link , $query);
$getinf = mysqli_fetch_array($suq);
if($suq){
$_SESSION['email'] = $getinf['email'] ;
$_SESSION['id'] = $getinf['id'] ;
$userID = $_SESSION['id'] ;
$query2 = "UPDATE `users` SET emailcode='$emailCode'
WHERE id='$userID'";
mysqli_query($link , $query2);
//********
$to = $getinf['email'] ;
$from = array("FROM: noreply@sadeqrasheed.com","Content-type: text/html");
$body = "email code =$emailCode <br/> ";
$subject = "Verify Email";
if(mail($to , $subject, $body , implode("\r\n",$from) )){
}
header("Location: verify.php");
在verify.php中,我回显了电子邮件会话,但是它为空,这意味着获取数组未获取信息
现在,正如我所说的,一切正常,查询正在将信息提交给数据库,而fetch数组未获取任何信息,为什么?
最佳答案
您正在进入数据库,这不会返回结果集。如果要取回数据,则需要INSERT
刚输入的行。
例:
$query = "INSERT INTO `users` VALUES('$fname','$lname','$email','".md5(md5($email).$password)."','$company_name','','','','','') ";
$suq = mysqli_query($link , $query);
$id = mysqli_insert_id($link);
$sql = "SELECT * FROM `users` WHERE `id`='" . $id . "'";
$query = mysqli_query($link, $sql);
$getinf = mysqli_fetch_array($query);
您可能还想研究面向对象的mysqli,因为它更易于阅读。