Guest User

Untitled

a guest
Aug 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. Displaying error messages based on form data in php
  2. <body>
  3. <script type="text/javascript"> <!-- put the jquery load stuff into here -->
  4. $(function(){
  5. $("#registration_form").load("views/register_form.php");});
  6. </script>
  7.  
  8.  
  9. <div class="topbar"><!-- Create the top bar layout-->
  10. <div class="fill">
  11. <div class="container">
  12. <a class="brand" href="#">Website!</a>
  13. <ul class="nav">
  14. <li class="active"><a href="#">Home</a></li>
  15. <li> <a href="#about">About</a></li>
  16. </ul>
  17. <form action="scripts/login_user.php" method="post" class="pull-right">
  18. <input class="input-medium" id="login-email" type="text" name="email_addr" placeholder="email" />
  19. <input class="input-medium" id="login-password" type="password" name="password" placeholder="password" />
  20. <button class="btn" type="submit">Login now!</button>
  21. </form>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="container">
  26. <div class="content">
  27. <div class="page header">
  28. Page header!
  29. </div>
  30. <div id="registration_form">
  31. </div>
  32.  
  33. if(//some of the data in the form isn't set)
  34. {
  35. //Set error conditions based on missing data
  36. }
  37.  
  38. $confirm_password=$_REQUEST['confirm_password'];
  39. $password=$_REQUEST['password'];
  40. if($confirm_password != $password){
  41. //report passwords don't match}
  42.  
  43.  
  44. $email_addr=$_REQUEST['email_addr'];
  45. $first_name=$_REQUEST['first_name'];
  46. $last_name=$_REQUEST['last_name'];
  47.  
  48.  
  49. try
  50. {
  51. $successful_creation=create_user_and_send_verification_email($email_addr, $password, $first_name, $last_name);
  52. }
  53. catch(Exception $e)
  54. {
  55. /*SQL errors are caught here*/
  56. }
  57.  
  58. if($successful_creation==FALSE)
  59. {
  60. //If it couldn't be inserted for a non exception generating reason. If I get here, should I echo a page that has those errors printed, but is otherwise identical to the previous one?
  61. }
  62. else
  63. {
  64. //redirect to a "wait for a verification email" page
  65. }
Add Comment
Please, Sign In to add comment