<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'moviefone';
$con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('can not connect to the database');
mysql_select_db($dbname, $con);
if (!empty($_POST['usernamesignup']) && !empty ($_POST['emailsignup']) && !empty($_POST['passwordsignup'])
&& !empty($_POST['passwordsignup']) && !empty($_POST['passwordsignup_confirm']))
{
$email = $_POST['emailsignup'];
$username = $_POST['usernamesignup'];
$password = $_POST['passwordsignup'];
$sql ="INSERT INTO users (email,username, password) VALUES ('$email', $username','$password')";
$result = mysql_query($sql);
if ($result) {
echo "you have registered successfully";
}
else {
echo "there was a problem";
}
}
else {
echo "Please confirm your information";
}
?>
这是html代码
<div id="register" class="animate form">
<form action="signup_ac.php" autocomplete="on" method="POST">
<h1> Sign up </h1>
<p>
<label for="usernamesignup" class="uname" data-icon="u">Your username</label>
<input id="usernamesignup" name="usernamesignup" required type="text" placeholder="mysuperusername690" />
</p>
<p>
<label for="emailsignup" class="youmail" data-icon="e" > Your email</label>
<input id="emailsignup" name="emailsignup" required type="email" placeholder="mysupermail@mail.com"/>
</p>
<p>
<label for="passwordsignup" class="youpasswd" data-icon="p">Your password </label>
<input id="passwordsignup" name="passwordsignup" required type="password" placeholder="eg. X8df!90EO"/>
</p>
<p>
<label for="passwordsignup_confirm" class="youpasswd" data-icon="p">Please confirm your password </label>
<input id="passwordsignup_confirm" name="passwordsignup_confirm" required type="password" placeholder="eg. X8df!90EO"/>
</p>
<p class="signin button">
<input type="submit" value="Sign up"/>
</p>
<p class="change_link">
Already a member ?
<a href="#tologin" class="to_register"> Go and log in </a>
</p>
</form>
</div>
我已经制作了一个简单的注册表单来测试它是否正常工作。但是当我尝试打开registration.php时它只显示please confirm your information
。有两个页面用于html registration.php和php signup_ac.php。我不明白为什么。如果问题出在我的php上,那么它应该显示我认为的形式。
答案 0 :(得分:5)
您需要学习调试代码:
if [...snip...] $POST_['passwordsignup_confirm'])){
^^^^^--- dyslexic moment?