Jump to content

kalzerd

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by kalzerd

  1. Hello and greetings fellow programmers!

     

    I am still new and learning PHP/HTML. This is my first project. What I have to do is to create a registration/login form and store the data in database then display the data stored. I created 3 pages which is registration form, connect.php and page3.php(use to display stored data).

     

    Here is my registration form :

    </head><body>    <div class="register-form"><h1>Register</h1><form action="connect.php" method="POST">    <p><label>User Name : </label>	<input id="username" type="text" name="Username" placeholder="username" /></p>		<p><label>E-Mail       : </label>	 <input id="password" type="email" name="Email" required placeholder="example@email.com" /></p>      <p><label>Password   : </label>	 <input id="password" type="password" name="Password" placeholder="password" /></p>	 	 <p><label>UserID     : </label>	 <input id="password" type="password" name="UserID" placeholder="ID" /></p>     <a class="btn" href="login.php">Login</a>    <input class="btn register" type="submit" name="submit" value="Register" />    </form></div></body></html>

    here is my connect.php :

    <html><body><?phpsession_start();$dbhost = "localhost";$dbuser = "root";$dbpass = "12345";$dbname = "student";$con = mysql_connect($dbhost,$dbuser,$dbpass);if (!$con){    die("Database Connection Failed" . mysql_error());}else{	$seldb = mysql_select_db($dbname);	if(!$seldb){		die("CANNOT SELECT Database");	}else{		header("Location: page3.php");	}}?></body></html>

    and here is my page3.php :

    <?php	require('connect.php');        if (isset($_POST['Username']) && isset($_POST['Password'])){        $username = $_POST['Username'];	$email = $_POST['Email'];        $password = $_POST['Password'];	$userid = $_POST['UserID'];         $query = "INSERT INTO `user` (Username, Email, Password, UserID) VALUES ('$username','$email','$password','$userid')";        $result = mysql_query($query);        if($result){            $msg = "User Created Successfully.";        }    }    ?>

    Ignore the page3.php for a while. My question is when I click register, it should go to connect.php to connect to database mysql and then proceed to page3.php and display "User Created Successfully", BUT it does not. When i click register, it just go to connect.php and display nothing. I did check my codes couple of times but still could not figure out what's wrong(**noted that i have my latest version of xampp running). I hope someone can help me because I'm out of idea. Sorry and Thanks!

×
×
  • Create New...