500内部错误,我的代码有什么问题?

时间:2013-12-05 18:48:58

标签: php internal

我的编码有点问题,我在运行此脚本时遇到500错误:

<?php
include_once("../../includes/connect.php");
if (isset($_POST['action']) && $_POST['action'] == "check"){
$email = mysql_real_escape_string(strip-tags($_POST['email']));
$username = mysql_real_escape_string(strip_tags($_POST['username']));

if (strpos($email,"@")!== false){
    $check_email = explode("@",$email);
    if (strpos($check_email[1],".")=== false){
        echo 3;
        exit();
    }
} else {
    echo 3;
    exit();
}
$email_query = mysql_query("SELECT id FROM users WHERE email='$email' LIMIT 1");
if (mysql_num_rows($email_query)== 1){
    //Email already exists
    echo 1;
    exit();
} else {
    $username_query = mysql_query("SELECT username FROM users WHERE username='$username' LIMIT 1");
    if (mysql_num_rows($username_query)== 1){
        //Username already exists
        echo 2;
        exit();
    } else {
        //Everything is fine
        echo 0;
        exit();
    }
}
}
if (isset($_POST['action']) && $_POST['action'] == "register"){
    $username = mysql_real_escape_string(strip_tags($_POST['username']));
    $password = mysql_real_escape_string(strip_tags($_POST['password']));
    $email = mysql_real_escape_string(strip_tags($_POST['email']));

    $activation_code = md5($username.$password);

    $reg_query = mysql_query("INSERT INTO users (username, password, email, activfation_code) VALUES ('$username', '".md5($password)."', '$email', '$activation_code')");
    if ($reg_query){
        //Successfully registered
        $new_userid = mysql_insert_id();
        //Create new users folder
        #mkdir("../users/$new_userid", 0755);
        //Create new users images folder
        #mkdir("../users/$new_userid/images", 0755);
        //Create new users media folder
        #mkdir("../users/$new_userid/media", 0755);

        $to = $email;
        $from = "noreply@atradiesinc.com";
        $subject = "Activate your Account!";

        $message = "<h3>Welcome to Atradies Inc Gaming Community, ".$username."!</h3>
        <p>To complete registration you must verify and activate your account. Click the link below and the magic shall happen.</p>
        <p><a href='http://www.atradiesinc.com/network/?id=$new_userid&activate=$activation_code'>http://www.atradiesinc.com/network/?id=$new_userid&activate=$activation_code</a></p>
        <p>Once your account has been activated, you may login and join in with the community with the details below:<br />
        <strong>Username: </strong>$username<br />
        <strong>Password: </strong><i>Password you supplied on registration</i></p>
        <p>Thank you and enjoy the community!</p>";

        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "From: $from\r\nReply-To: $from";
        mail($to, $subject, $message, $headers);

        echo 1;
        exit();

    } else {
        //Registration failed
        echo 0;
        exit();
    }
}

?>

问题是什么?我似乎无法找到它的任何问题。它是代码,还是服务器我试用它?我已经尝试过Chrome Inspect Element控制台,它不会再提供该文件上的“500内部服务器错误”信息。

谢谢!

1 个答案:

答案 0 :(得分:0)

你在第三行有一点错字:

$email = mysql_real_escape_string(strip-tags($_POST['email']));

应该是

$email = mysql_real_escape_string(strip_tags($_POST['email']));

看看评论,它们非常重要。