0

The values wont insert into my database, the message tells me that registration is complete but nothing gets stored in database, please help. Thanks!

Your post does not have much context to explain the code sections; please explain your scenario more clearly.

Heres code:

$submit = $_POST['submit'];

$name = strip_tags($_POST['fullnamefield']);
$regemail = strip_tags($_POST['regemailfield']);
$password = strip_tags($_POST['regpasswordfield']);
$repeatpassword = strip_tags($_POST['regpasswordconfirmfield']);
$date = date("Y-m-d");

if ($submit)
{

    if ($name&&$regemail&&$password&&$repeatpassword)
    {

        if ($password==$repeatpassword)
        {

        if (strlen($name)>32||strlen($regemail)>1024)
        {
         echo "Length of name or email is too long.";
        }
        else
        {
        if (strlen($password)>32||strlen($password)<6)
        {
        echo "Password must be between 6 and 32 characters long.";
        }
        else
        {

        $password = md5($password);
        $repeatpassword = md5($repeatpassword);

        $connect = mysql_connect("xx","xx","xx");
        mysql_select_db("xx");

        $queryreg = mysql_query("

        INSERT INTO users VALUES ('','$name','$regemail','$password','$date')

        ");

        die("You have been registered!");

        }

        }
        }
        else
            echo "Your passwords do not match";
    }
    else
        echo "Please fill in all fields.";

}
4

1 回答 1

0

要获得一些诊断信息,我会添加

or die(mysql_error());

到您的 mysql_query 语句制作最后一行

$queryreg = mysql_query("

    INSERT INTO users VALUES ('','$name','$regemail','$password','$date')

    ") or die (mysql_error());

这将输出mysql在查询期间出现的任何错误。如果您不确定自己在看什么,请将它们发回此处。

希望这可以帮助。

于 2012-06-08T04:42:03.417 回答