我正在创建一个帐户创建表单提交PHP脚本。但是,查询进入无限循环。它会不断地将条目添加到数据库中,直到我关闭页面。为什么这样做?非常感谢!
<?php require 'dbconnect.php'; ?>
<?php
//If sign up submit POST recieved
if (isset($_POST['suEmail']))
{
$suFirstName = mysqli_real_escape_string($connection, $_POST['suFirstName']);
$suLastName = mysqli_real_escape_string($connection, $_POST['suLastName']);
$suEmail = mysqli_real_escape_string($connection, $_POST['suEmail']);
$suPassword = mysqli_real_escape_string($connection, $_POST['suPassword']);
$suDisplayName = mysqli_real_escape_string($connection, $_POST['suDisplayName']);
$confirmCode = substr(md5(mt_rand()),0,15);
$query = $connection->query("INSERT INTO users (firstName,lastName,email,password,displayName,confirmCode,verified)Values('{$suFirstName}','{$suLastName}','{$suEmail}','{$suPassword}','{$suDisplayName}','{$confirmCode}','0')");
if ($query)
{
echo "query SUCCESS";
$subject = "Learncyclopedia Email Verification";
$headers = "From: noreply@learncyclopedia.com \r\n";
$headers .= "Reply-To: noreply@learncyclopedia.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message.='<div style="width:550px; background-color:#CC6600; padding:15px; font-weight:bold;">';
$message.='Learncyclopedia Email Verification';
$message.='</div>';
$message.='<div style="font-family: Arial;">Hello '.$suFirstName.'<br/>';
$message.='Click on the link below to verify your account<br>';
$message.="<a href='http://79.170.40.236/learncyclopedia.com/user-confirmation.php?email=$suEmail&confirmation_code=$confirmCode'>click</a>";
$message.='</div>';
$message.='</body></html>';
mail("123@gmail.com",$subject,$message,$headers);
}
}
?>
答案 0 :(得分:0)
检查提交按钮名称。我觉得你搞砸了这个
suEmail,$ suEmail = mysqli_real_escape_string($ connection,$ _POST ['suEmail']);