嘿所以我正在制作一个注册页面,一切正常,但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中的我回应了电子邮件会话,但它是空的,这意味着获取数组没有获取信息 现在正如我所说的一切正常,查询是将信息提交到DB位,获取数组没有得到任何信息任何想法为什么?
答案 0 :(得分:0)
您INSERT
进入数据库,这不会返回结果集。如果您想要获取数据,则需要SELECT
您输入的行。
示例:
$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,因为它更清晰易读。