0
<?php include_once("scripts/global.php");
if(isset($_POST["username"])){

    $username = $_POST["username"];
    $fname = $_POST["fname"];
    $lname = $_POST["lname"];
    $email = $_POST["email"];
    $pass1 = $_POST["pass1"];
    $pass2 = $_POST["pass2"];

    //error handling
    if((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)){
        $message ="Please insert all the fields!!"; 
    }else {
        if($pass1!=$pass2){
            $message="Your password fields do not match!!";
        }else{
            //securing the data
            $username = preg_replace("#[^0-9a-z]#i","",$username);
            $fname = preg_replace("#[^0-9a-z]#i","",$fname);
            $lname = preg_replace("#[^0-9a-z]#i","",$lname);
            $pass1 = sha1($pass1);

            $email = mysql_real_escape_string($email);
            //check the duplicates
            $user_query = mysql_query("SELECT username FROM members WHERE username='$username' LIMIT 1") or die("Could Not check username");
            $count_username = mysql_num_rows($user_query);

            $email_query = mysql_query("SELECT email FROM members WHERE email='$email' LIMIT 1") or die("Could Not check email");
            $count_email = mysql_num_rows($email_query);
            if($count_username>0){
                $message = "your username is already in use!!";
            }else if($count_email>0){
                $message = "Your email is already in use!!";
            }else{
                //insert the members
                $ip_address = $_SERVER['REMOTE_ADDR'];
                $query =mysql_query("INSERT INTO members(username,firstname,lastname,email,password,ip_address,sign_up_date) VALUES('$username','$firstname','$lastname','$email','$pass1','$ip_iddress',now())") or die(mysql_error());

                $member_id = mysql_insert_id();
                mkdir("users/$member_id",0755);
                $message="You Have been registered";
            }
        }
    }

?>

我在 DW 中遇到语法错误,我在 localhost 中运行文件..当我在 HTML 代码的段落标签中包含 message 变量时:

<p><?php print("$message");?></p>
4

1 回答 1

2

您忘记了脚本末尾的括号 }

于 2012-10-03T09:54:44.483 回答