Guest User

Untitled

a guest
Jan 6th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2. session_start();
  3. /*$server = 'v.je';
  4. $username = 'student';
  5. $password = 'student';
  6. //The name of the schema we created earlier in MySQL workbench
  7. //If this schema does not exist you will get an error!
  8. $schema = 'accounts';*/
  9. //^^THIS CONNECTS TO THE DATABASE USING A DIFFERENT METHOD^^
  10. $pdo = new PDO ("mysql:host=v.je;dbname=accounts","student","student");
  11. [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
  12. //$results = $pdo->query('SELECT * FROM users');
  13.  
  14. if(isset($_POST['submit'])){
  15. $username = $_POST['username'];
  16. $password = $_POST['password'];
  17. $email = $_POST['email'];
  18. $userStatus = $_POST['userStatus'];
  19.  
  20.  
  21. $insert = $pdo->prepare("INSERT INTO users
  22. (username,password,userStatus,email)
  23. values(:username,:email,:password,:userStatus) ");
  24. $insert->bindParam(':username',$username);
  25. $insert->bindParam(':password',$password);
  26. $insert->bindParam(':userStatus',$userStatus);
  27. $insert->bindParam(':email',$email);
  28.  
  29.  
  30. $cmtd = $insert->execute();//committed the insert tasks to the database
  31.  
  32.  
  33. if($cmtd){
  34. //$_SESSION['email'] = $email;
  35. // $_SESSION['username'] = $username;
  36. // $_SESSION['userStatus'] = 'cust';
  37. header('location:index.php');
  38. }
  39. else{
  40. echo 'Something went wrong!';
  41. }
  42. }
  43.  
  44. ?>
  45.  
  46.  
  47. <h2>Register Account</h2>
  48. <form action="form.php" method="POST">
  49. <label>Username:</label> <input type="text" name="username" />
  50. <label>Password:</label> <input type="text" name="password" />
  51. <label>Email:</label> <input type="text" name="email" />
  52. <input type="hidden" name="userStatus" value="cust">
  53.  
  54.  
  55. <input type="submit" name="submit" value="Register" />
  56.  
  57. <p>
  58. Already a member? <a href="/assignment/login.php">Login</a>
  59. </p>
  60. </form>
Add Comment
Please, Sign In to add comment