我需要一个注册按钮,它可以将数据发送到mySQL服务器,也可以在单击时重定向


I need a registration button that sends data to a mySQL server to also Redirect on click

所以我在我的网站上做了一个注册页面。目前,这更像是一次测试,而不是任何事情。我让它或多或少地工作,当用户试图注册时,它工作得很好,但页面上没有变化。我已经创建了一个确认页面,但无论我尝试什么,我似乎都无法获得重定向按钮。

    <form name="register" method="post" action="register.php">
        Username:<input name="user" type="text" id="user">
        <br>
        Password:<input name="pass" type="password" id="pass">
        <br>
        Repeat Password:<input name="rpass" type="password" id="rpass">
        <br>
        <input type="submit" name="submit" value="Register">
    </form> 

从我在最后几个小时的研究中可以看出,点击并将按钮包装在链接中不起作用的原因是因为type="submit"而不是"button"。有什么方法可以让这个按钮重定向吗?如果不是HTML,也许是JS或PHP?

    <?php
session_start();  //Must Start a session.
require "config.php"; //Connection Script, include in every file!
//Check to see if the user is logged in.
//'isset' check to see if a variables has been 'set'
if(isset($_SESSION['username'])){
   header("location: members.php");
}
//Check to see if the user click the button
if(isset($_POST['submit']))
{
   //Variables from the table
   $user  = $_POST['user'];
   $pass  = $_POST['pass'];
   $rpass = $_POST['rpass'];
   //Prevent MySQL Injections
   $user  = stripslashes($user);
   $pass  = stripslashes($pass);
   $rpass = stripslashes($rpass);
   $user  = mysqli_real_escape_string($con, $user);
   $pass  = mysqli_real_escape_string($con, $pass);
   $rpass = mysqli_real_escape_string($con, $rpass);
   //Check to see if the user left any space empty!
   if($user == "" || $pass == "" || $rpass == "")
   {
      echo "Please fill in all the information!";
   }
   else
   {
      //Check too see if the user's Passwords Matches!
      if($pass != $rpass)
      {
         echo "Passwords do not match! Try Again";
      }
      //CHECK TO SEE IF THE USERNAME IS TAKEN, IF NOT THEN ADD USERNAME AND PASSWORD INTO THE DB
      else
      {
         //Query the DB
         $query = mysqli_query($con,"SELECT * FROM members WHERE username = '$user'") or die("Can not query the TABLE!");
         //Count the number of rows. If a row exist, then the username exist!
         $row = mysqli_num_rows($query);
         if($row == 1)
         {
            echo "Sorry, but the username is already taken! Try again.";
         }
         //ADD THE USERNAME TO THE DB
         else
         {
            $add = mysqli_query($con,"INSERT INTO members (id, username, password) VALUES (null, '$user' , '$pass') ") or die("Can't                Insert! ");
         }

      }      
   }
}
?>

正如我所评论的,只需执行

     else
     {
        $add = mysqli_query($con,"INSERT INTO members (id, username, password) VALUES (null, '$user' , '$pass') ") or die("Can't Insert! ");
        header("location: thankyou.html"); 
     }