Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <center>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>Sign Up</title>
  10. <link rel="stylesheet" href="style.css" />
  11. </head>
  12. <body>
  13. <?php
  14. require('db.php');
  15. session_start();
  16. // If form submitted, insert values into the database.
  17. if (isset($_POST['username'])) {
  18.     $username = $_POST['username'];
  19.     $password = $_POST['password'];
  20.     $pin      = $_POST['pin'];
  21.     $username = stripslashes($username);
  22.     $username = mysql_real_escape_string($username);
  23.     $password = stripslashes($password);
  24.     $password = mysql_real_escape_string($password);
  25.     $pin = mysql_real_escape_string($pin);
  26.  
  27.     //Checking is user existing in the database or not
  28.     $query    = "SELECT * FROM `users` WHERE username='$username' and password='" . md5($password) . "'";
  29.     $result = mysql_query($query) or die(mysql_error());
  30.     $rows = mysql_num_rows($result);
  31.     if ($rows == 1) {
  32.         $_SESSION['username'] = $username;
  33.         header("Location: index.php"); // Redirect user to index.php
  34.     } else {
  35.         echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
  36.     }
  37. } else {
  38. ?>
  39. <div class="form">
  40. <body style="margin-top: 5cm;">
  41. <body bgcolor="#ECECEA">
  42. <img src="lock_image.png" alt="Lock Image" style="width:90px;height:90px;">
  43. <font face="verdana" color="grey"><h1>SIGN UP</h1></font>
  44. <form action="" method="post" name="login">
  45. <input type="text" name="username" placeholder="Username" required />
  46. <input type="password" name="password" placeholder="Password" required />
  47. <input type="pin" name="pin" placeholder="Pin" required />
  48. <input name="submit" type="submit" value="Sign up" />
  49. </form>
  50. <p style="font-family:verdana;">Already Have an Account? <br ><a href='registration.php'>Click Here To Sign In</a></p>
  51. </div>
  52. <?php
  53. }
  54. ?>
  55. </center>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement