gpt4 book ai didi

mysql - MySQL 的另一个问题 - 简单的注册表显示空白屏幕,没有错误

转载 作者:行者123 更新时间:2023-11-29 09:06:55 27 4
gpt4 key购买 nike

好吧,相信我,我已经坐在这里盯着这个看了很长时间了。我一生都无法弄清楚出了什么问题。

即使打开它们,我也没有收到任何错误消息。当我删除 die 语句时,它会在末尾显示文本,因此这肯定是一个 SQL 错误。啊,我讨厌 SQL!

<?php

include('functions.php');

if(!$_POST['regtype'] || !$_POST['regemail'] || !$_POST['regpass'] || !$_POST['regpass2']) {
"You didn't fill out a required field.";
exit();
}
if($_POST['regpass'] != $_POST['regpass2']) {
"Your passwords didn't match.";
exit();
}


$regtype = protect($_POST['regtype']);
$regemail = protect($_POST['regemail']);
$regpass = protect($_POST['regpass']);
$secregpass = sha1($regpass);
$regdate = date("Y/m/d");


// seems to be right below here

$checksql = "SELECT * FROM profile WHERE email = '$regemail'";
$checkquery = mysql_query($checksql,$connect) or die(mysql_error());
$checknumrows = mysql_num_rows($checkquery) or die(mysql_error());
if($checknumrows > 0) {
"A user with that email already exists!";
exit();
} else {

$inssql = "INSERT INTO profile (email, pass, type, regdate) VALUES ('$regemail', '$secregpass', '$regtype','$regdate')";
$insquery = mysql_query($inssql, $connect) or die(mysql_error());


//these are just some of my notes
//need to make confirmation mail script later - or use donation verification as everything. def need to set up mail server


$_SESSION['email'] = $regemail;

echo "You have successfully registered.
<br /><br />
You're almost done! Please pick the charity you would like to donate to, and how much you would like to donate (minimum of $25).
<br /><br />
If you can't decide, you can donate to our general fund, which is equitably distributed to each charity (and is not handled by us!).
<br /><br />
<form action='donate.php' method='get'>
Charity:
<br /><br />
<select>
<option name='charity' value='1'>Charity 1</option>
<option name='charity' value='2'>Charity 2</option>
<option name='charity' value='3'>Charity 3</option>
</select>
<br /><br />
USD: $<input type='text' name='amount' />
";
}


?>

顺便说一句,这是“保护”功能:

function protect($string){
$string = trim(strip_tags(addslashes($string)));
return $string;

}

最佳答案

布拉德,这可能就是问题所在;

$checknumrows = mysql_num_rows($checkquery) 或 die(mysql_error());

如果配置文件不包含给定的电子邮件,mysql_num_rows($checkquery) 将为 0,因此它执行 die(mysql_error()) 但没有错误,因此die() 不打印任何内容。简而言之,摆脱或死(mysql_error())

关于mysql - MySQL 的另一个问题 - 简单的注册表显示空白屏幕,没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6800011/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com