概述
我正在尝试创建一个帐户注册页面,当我添加一个系统来检查数据库并确保没有多个具有相同用户名的行时,出现500错误.
这是有效的代码:
if(isset ($_POST['submit']))
{
include( 'connection.php' );
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
if(empty($username) || empty($email) || empty($password))
{
echo 'Please check the required fields.';
}
elseif(!filter_var($email,FILTER_VALIDATE_EMAIL))
{
echo 'Please enter a correct email address.';
}
else
{
$password = md5($password);
$sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password')") or die(mysql_error());
if($sql)
{
echo 'Successfully submitted.';
}
}
}
?>
这是给我500错误的代码:
error_reporting(E_ALL)
if(isset ($_POST['submit'])) {
include( 'connection.php' );
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$fetch = mysql_query("SELECT * FROM users WHERE username = '$email'") or die(mysql_error();
$num_rows = mysql_num_rows($fetch);
if(empty($username) || empty($email) || empty($password)) {
echo 'Please check the required fields.';
}
elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
echo 'Please enter a correct email address.';
}
elseif($num_rows >= 1);
{
echo 'This username is taken.';
else
}
$password = md5($password);
$sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password')") or die(mysql_error());
if($sql)
{
echo 'Successfully submitted.';
}
}
}
?>
最后
以上就是会撒娇小兔子为你收集整理的php执行出现500,为什么我的PHP总是出现500错误?的全部内容,希望文章能够帮你解决php执行出现500,为什么我的PHP总是出现500错误?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复