dongzhi9906 2015-05-10 05:18
浏览 60

当我加载我的PHP页面然后提交按钮自动按和页面再次加载?

I'm using wamp server php my admin sql,table created connection every thing is fine,I'm working on local host, but page again and gain loading, not move down cursor etc, submit button automatically click ?

Here is screen shot http://i.imgur.com/QC6RtAg.jpg?1

       <center><form method="post">
       <table border="0" cellspacing="8">
       <tr>
          <td><label><b>*Select Campus:</b></label></td>
             <td>
            <select name="city" id="city">
                <option value="">-Please Select-</option>
                <option value="Isb">Islamabad</option>
                <option value="Abt">Abbotabad</option>
                <option value="wah">Wah</option>
                <option value="Atk">Attock</option>
                <option value="shw">Sahiwal</option>
                <option value="veh">Vehari</option>
                <option value="vir">Virtual</option>
            </select>
            <font color="red"><?php echo @$_GET['campus'];?></font>
       </td>
    </tr>
    <tr>
    <td><label><b>*Name</b></label></td>
    <td><input type="text" name="name" /> 
   <font color="red"><?php echo @$_GET['newname'];?></font>
   <td></tr>
   <br/>
    <tr>
   <td><label><b>*Login</b></label></td>
    <td><input type="text" name="logid"/>
    <font color="red"><?php echo @$_GET['logname'];?></font> 
    <td></tr>
    <br/>
    <tr>
   <td><label><b>*Email Address</b></label></td>
   <td><input type="text"type="require" name="email"/>
   <font color="red"><?php echo @$_GET['emailname'];?></font>
   </td></tr>
   <br/>
   <tr>
   <td><label><b>*Password</b></label></td>
   <td><input type="password" type="require" name="pass"/>
  <font color="red"><?php echo @$_GET['passname'];?></font>
  </td></tr>
 <br/>
 <tr>
<td><label><b>*Retype Password</b></label></td>
<td><input type="password" type="require" name="rpass"/>
<font color="red"><?php echo @$_GET['rpassname'];?></font>
</td></tr>

 </table>
 <table border="0">
 <tr id="bu">
 <td ><input type="submit" id="cl" value="sign up"name="submit"/></td>    </tr>

 </table>
 </form>
 </center>










 <?php
 $conn = mysqli_connect('localhost', 'root' , '','example');
 if(isset($_POST['submit']))<?php
 { 
$campus=$_POST['city'];
$name = $_POST['name'];
$u_id = $_POST['logid'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$rpass = $_POST['rpass'];
if($campus==''){
echo
"<script>window.open('Log.php?campus=Select campus is    Required','_self')    
</script>";
exit();
}
if($name==''){
echo
"<script>window.open('Log.php?newname=Name is Required','_self')   </script>";
 exit();
 if($u_id==''){
echo
"<script>window.open('Log.php?logname=User ID is Required','_self')</script>";
        exit();
   }
   if($email==''){
   echo
  "<script>window.open('Log.php?emailname=Email is Required','_self')      </script>";
   exit();
  }
  if($pass==''){
   echo
   "<script>window.open('Log.php?passname=Password is Required','_self')   </script>";
    exit();
   }
   if($rpass==''){
   echo
   "<script>window.open('Log.php?rpassname=Password is Required','_self')  </script>";
exit();


}


 $sql = "INSERT INTO      student(Campus,User_id,Login,Email,password,Retype_password)    values('$campus','$name','$u_id','$email','$pass','$rpass')";

 if (mysqli_query($conn,$sql) {
echo "New record created successfully";
 print '<script>alert("Successfully Registered!");</script>'; // Prompts   the user
    print '<script>window.location.assign("login.php");</script>'; //   redirects to register.php
}     else {
 echo "Error: " . $sql . "<br>" . $conn->error;
 }$conn->close();
 }
?> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥50 汇编语言除法溢出问题
    • ¥65 C++实现删除N个数据列表共有的元素
    • ¥15 Visual Studio问题
    • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波