提交表单后标题为同一页面

时间:2017-05-30 05:32:59

标签: javascript php forms location

我有一个创建新帐户的注册页面,我尝试做的是在提交表单后保持在同一页面,我尝试使用标题位置,但仍然doensnt工作。应该是当我提交表格时,警报按钮会弹出,但注册表格不会消失

<?php
    require('db1.php');

    if (isset($_REQUEST['username'])){
        $username = stripslashes($_REQUEST['username']);
        $username = mysqli_real_escape_string($con,$username);
        $name = stripslashes($_REQUEST['name']);
        $name = mysqli_real_escape_string($con,$name);
        $email = stripslashes($_REQUEST['email']);
        $email = mysqli_real_escape_string($con,$email);
        $password = stripslashes($_REQUEST['password']);
        $password = mysqli_real_escape_string($con,$password);

        $trn_date = date("Y-m-d H:i:s");
        $query = "INSERT into `users` (username, name, password, email, trn_date) VALUES ('$username', '".md5($password)."', '$email', '$name', '$trn_date')";
        $result = mysqli_query($con,$query);
        if($result){

           echo '<script language="javascript">';
           echo 'alert("Succesfully Registered")';
           echo '</script>';
           header("Location: register.php");
exit;
        }
    }else{
?>

我的表格:          

<div class="panel panel-info">
  <div class="panel-heading"><center>Manage Account - Admin</center></div>
  </div>
  </div>
  </div>

<div class="row">
<div class="form">
<div class="col-md-4 col-centered">
<div class="panel panel-info">
      <div class="panel-heading">Register New Account</div>
      <div class="panel-body">
    <form name="registration" action="" method="post">
        <div id="mail-status"></div>
         <div>
          <label>Full Name:</label>
          <br/>
          <input type="text" name="name" placeholder="Enter Full Name" required /><br>
        </div>
        <div>
          <label>Username:</label>
          <br/>
          <input type="text" name="username" placeholder="Enter Username" required /><br>
        </div>
        <div>
          <label>Email:</label>
          <br/>
          <input type="text" name="email" placeholder="Enter Email Address" required /><br>
        </div>
        <div>
          <label>Password:</label>
          <br/>
          <input type="text" name="password" placeholder="Enter Password" required /><br>
        </div>  
        </div>
        <div>
          <input type="submit" value="Send" class="btnAction" />
        </div>
      </form>
</div>
    </div>
    </div>
    </div>
    </div>

0 个答案:

没有答案