2016-04-10 42 views
0

我不知道是什么原因导致了这个问题。我有注册表单,每当我尝试点击“完成注册”按钮时,都没有任何反应!表格甚至没有提交!这是HTML:为什么我的表单提交我的表单不可点击?

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8" name="viewport" content="width=device-width, height=device-height, initial-scale = 1"> 
     <title>Signup</title> 
     <link rel="icon" href="/images/favicon.ico" type="image/x-icon"> 
     <link rel="stylesheet" href="/styling/signupstyle.css"> 
    </head> 

    <body> 
     <div id="formdiv" method="post"> 
      <h1 id="title">Sign Up Here!</h1> 
      <form id="form" name="signupform" onsubmit="return false;"> 
       <div class="inputdiv"> 
        <label for="username">Username: </label> 
        <input name="username" type="text" maxlength="20"> 
        <span id="unamestatus"></span> 
       </div> 
       <div class="inputdiv"> 
        <label for="password">Password: </label> 
        <input type="password" name="pass1" maxlength="20"> 
       </div> 
       <div class="inputdiv"> 
        <label for="pass2">Confirm Password: </label> 
        <input type="password" name="pass2" maxlength="20"> 
       </div> 
       <div class="inputdiv"> 
        <label for="email">Email: </label> 
        <input name="email" type="text" maxlength="100"> 
       </div> 
       <div class="inputdiv"> 
        <label for="gender">Gender: </label> 
        <select name="gender""> 
         <option value=""></option> 
         <option value="m">Male</option> 
         <option value"f">Female</option> 
        </select> 
       </div> 
       <div class="inputdiv"> 
        <label for="country">Country: </label> 
        <select name="country"> 
         <?php include_once("countries.html"); ?> 
        </select> 
       </div> 
       <div> 
        <input id="submit" type="submit" name="submit" value="Complete Registration!" style="width: 40%; font-size: 25px; padding: 1% 0;"> 
       </div> 
       <div style="margin-top: 5%;"> 
        <img src="/images/ConnectionLogo.PNG" alt="Connection" style="width: 25%; height: 25%;"> 
       </div> 
      </form> 
     </div> 
    </body> 

</html> 

这是形式的造型:

body { 
width: 100vw; 
height: 100vh; 
font-size: 25px; 
background: linear-gradient(to right, #3DCBF2 , #3DF2D4); 
overflow-x: hidden; 
overflow-y: hidden; 
} 

#formdiv { 
margin: auto; 
width: 50%; 
height: 85%; 
border: 5px solid #2A67EB; 
background-color: #37A3F0; 
position: absolute; 
top: 0; left: 0; bottom: 0; right: 0; 
} 

#form { 
width: 70%; 
margin: 0 auto; 
text-align: center; 
height: 90%; 
} 

#title { 
text-align: center; 
color: #57E7F7; 
margin-top: 1%; 
} 

#form input { 
width: 35%; 
font-size: 20px; 
background-color: #70D1FA; 
border: 3px solid #4187E8; 
color: #376BE6; 
} 

#form select { 
width: 25%; 
font-size: 20px; 
background-color: #70D1FA; 
border: 3px solid #4187E8; 
color: #376BE6; 
} 

.inputdiv { 
padding-bottom: 5%; 
} 

#form label { 
margin-right: 3%; 
color: #3544F0; 
font-weight: bold; 
} 

这是一个尚未完成的PHP,但肯定不是造成问题的原因:

if ($_POST['submit']) { 
// Receiving data from the form // 
$username = preg_replace('#[^a-z0-9]#i', '', $_POST['username']); 
$usercheck = mysqli_query($connection, "SELECT * FROM users WHERE username='$username'"); 
$password = mysqli_real_escape_string($connection, $_POST['pass1']); 
$passconfirm = mysqli_real_escape_string($connection, $_POST['pass2']); 
$email = mysqli_real_escape_string($connection, $_POST['email']); 
$emailcheck = filter_var($email, FILTER_VALIDATE_EMAIL); 
$emailcheck2 = mysqli_query($connnection, "SELECT * FROM users WHERE email='$email'"); 
$gender = mysqli_real_escape_string($connection, $_POST['gender']); 
$country = mysqli_real_escape_string($connection, $_POST['country']); 
// Now for the check functions // 
if ($usercheck != 0) { 
    die("Sorry, your username is already in use! Redirecting..."); 
}; 
if ($password != $passwordconfirm) { 
    die("The passwords do not match! Redirecting..."); 
}; 
if ($emailcheck != 0) { 
    die("That email is already in use! Redirecting..."); 
}; 

};

+0

是否控制台报告任何错误? – Wowsk

+0

页面是否刷新?该按钮是不是可点击的? –

回答

2

因为您明确地取消了提交操作。你说onsubmit="return false;"。当你明确地告诉它什么都不做时,你期待它做什么?

此外,阿里纳斯,你有一些HTML的问题:

<select name="gender""> 
    <option value=""></option> 
    <option value="m">Male</option> 
    <option value"f">Female</option> 

应该是:

<select name="gender"> 
    <option value=""></option> 
    <option value="m">Male</option> 
    <option value="f">Female</option> 
+0

我忘了我甚至把它放在那里!谢谢你的收获! –

相关问题