ishaan2

signup.php

Aug 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. include 'resource/database.php';
  4. if(isset($_POST['email'])){
  5.     $email = $_POST['email'];
  6.     $username = $_POST['username'];
  7.     $password = $_POST['password'];
  8.  
  9. try{
  10.     $sqlInsert = "INSERT INTO user(username, password, email,join_date) VALUES(:username,:password,:email,now())";
  11.  
  12.  
  13.     $statement = $db->prepare($sqlInsert);
  14.  
  15.     $statement->execute(array(':username'=>$username, ':email'=>$email, ':password'=>$password));
  16.  
  17.     if($statement->rowCount() == 1){
  18.         $result = "<p style = 'padding: 20px; color: green;'>Registration Successful</p>";
  19.     }
  20.  
  21. }catch(PDOException $ex){
  22.     $result = "<p style = 'padding: 20px; color: red;'>Registration Not Successful ".$ex->getMessage()."</p>";
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. ?>
  30.  
  31.  
  32.  
  33.  
  34. <!DOCTYPE html>
  35. <html>
  36. <head lang = "en">
  37. <meta charset = "UTF-8">
  38. <title>Register page</title>
  39. </head>
  40. <body>
  41.  
  42.  
  43. <h2>User Authentication System</h2><br>
  44.  
  45.  
  46. </body>
  47.  
  48.  
  49.  
  50.  
  51. <h3>Register Form</h3>
  52.  
  53.  
  54.  
  55. <?php if(isset($result))
  56.                     echo $result;
  57.  
  58. ?>
  59.  
  60. <form method = "post" action = "">
  61.     <table>
  62.         <tr>
  63.             <td>Email: </td>
  64.             <td><input type = "text" value = "" name = "email"></td>
  65.         </tr>
  66.         <tr>
  67.             <td>Username: </td>
  68.             <td><input type = "text" value = "" name = "username"></td>
  69.         </tr>
  70.         <tr>
  71.             <td>Password: </td>
  72.             <td><input type = "password" value = "" name = "password"></td>
  73.         </tr>
  74.         <tr><td></td><td><input style = "float:right;" type = "submit" value = "Signup"></td></tr>
  75.     </table>
  76. </form>
  77.  
  78. <p><a href = "index.php">Back</a></p>
  79.  
  80.  
  81. </html>
Add Comment
Please, Sign In to add comment