下面的腳本不會像它應該的那樣工作。當我在我的網站上進入並輸入所有字段時,仍然會顯示'所有字段都是必需的'。我在這個網站上對腳本進行了一些修改:http://www.abell12.com/。你必須註冊才能下載它,但一旦你做了,點擊腳本,然後點擊PHP,然後進入登錄和註冊並下載腳本。這是我的腳本版本:PHP註冊腳本說所有字段都是必填的當所有填寫
<?php
if(isset($_POST['submit']))
{
$name = mysql_real_escape_string($_POST['name']);
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$password1 = mysql_real_escape_string($_POST['password1']);
$enc_password = md5($password);
if($name && $username && $password && $password1)
{
if(strlen($name)<30)
{
if(strlen($username)<10)
{
if(strlen($password)<30 || strlen($password)>6)
{
if($password == $password1)
{
require "dbc.php";
$query = mysql_query("INSERT INTO users VALUES ('','$name','$username','$enc_password')");
echo "Registration Complete! <a href='loginpage.php'>Click here to login</a>";
}
else
{
echo "Passwords must match";
}
}
else
{
echo "Your password must be between 6 and 30 characters";
}
}
else
{
echo "Your username is too long";
}
}
else
{
echo "Your name is too long";
}
}
else
{
echo "All fields are required";
}
}
?>
<html>
<form action="register.php" method="POST">
Name: <input type="text" name="name" value="<?php if(isset($_POST['submit'])){echo "$name";} ?>"> Max Length:30<p>
Username: <input type="text" name="username" value="<?php if(isset($_POST['submit'])){ echo "$username";} ?>"> Max Length:15<p>
Password: <input type="password" name="password"> Max length:30<p>
Re-Enter Password: <input type="password" name="password1"><p>
<input type="submit" name="submit" value="Register">
</form>
</html>
如果您需要更多的信息,請隨時問我。
請呼應,如果條件之前: - 回聲$名稱 '&&' $用戶名 '&&' $密碼 '&&' $密碼1;退出;。。。。並檢查每個字段是否得到張貼。 – rahul