if (!mail($to,$subject,$body,$headers))
{
echo "We couldn't sign you up at this time. Please try again later.";
if(!$email)
{
//register into database
$register = mysql_query("INSERT INTO `register2`(`username`, `password`, `email`, `code`, `0`, `active`, `First_name`, `Last_name`, `Mobile_number`, `Landline_number`, `sex`) VALUES ('$username', '$password', '$email', '$code', '0', '$active', '$name', '$lname', '$mobile', '$lline', '$sex')");
$result = mysql_query($register);
if($result!=0)
{
@session_start();
$_SESSION["email"]=$_POST["email"];
echo "You have been registered successfully! Please check your email ($email) to activate your account";
header("location:signup2.php");
}
}
}
如何执行it.means我有这3个condotion如何执行它,问题是我的phpmyadmin.pls中没有插入数据帮助我....
答案 0 :(得分:1)
根据您提供的代码,如果PHP mail()没有失败,您似乎想要运行INSERT查询。
之后,您正在尝试确认INSERT查询是否已返回成功标志,以便您可以继续执行步骤02.
如果我对您的问题的解释是正确的:
// If the PHP main returns FALSE
if (!mail($to,$subject,$body,$headers)) {
// user message with error
echo "We couldn't sign you up at this time. Please try again later.";
}
else {
//register into database
$register = mysql_query("INSERT INTO `register2`(`username`,`password`,`email`,`code`,`0`,`active`,`First_name`,`Last_name`,`Mobile_number`,`Landline_number`,`sex`) VALUES ('$username','$password','$email','$code','0','$active','$name','$lname','$mobile','$lline','$sex')");
$result = mysql_query($register);
}
// if variable $result is TRUE
if ($result) {
@session_start();
$_SESSION["email"]=$_POST["email"];
echo "You have been registered successfully! Please check your email ($email) to activate your account";
header("location:signup2.php");
}
编码风格!
这只是对代码缩进的警告。分析php.net Manual提供的示例,以掌握适当的代码缩进,以便其他人能够很好地阅读它。
PHP Basic syntax
PHP if,else,elseif/else if或任何其他control structure
作为您问题背后的主要问题,这些链接应该证明是有用的。
PHP mysql_query()返回值:
对于其他类型的SQL语句, INSERT ,UPDATE,DELETE,DROP等,mysql_query()成功时返回TRUE,错误时返回FALSE。 对于其他类型的SQL语句,INSERT,UPDATE,DELETE,DROP等,mysql_query()在成功时返回 TRUE ,在错误时返回 FALSE 。