Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Displaying error messages based on form data in php
- <body>
- <script type="text/javascript"> <!-- put the jquery load stuff into here -->
- $(function(){
- $("#registration_form").load("views/register_form.php");});
- </script>
- <div class="topbar"><!-- Create the top bar layout-->
- <div class="fill">
- <div class="container">
- <a class="brand" href="#">Website!</a>
- <ul class="nav">
- <li class="active"><a href="#">Home</a></li>
- <li> <a href="#about">About</a></li>
- </ul>
- <form action="scripts/login_user.php" method="post" class="pull-right">
- <input class="input-medium" id="login-email" type="text" name="email_addr" placeholder="email" />
- <input class="input-medium" id="login-password" type="password" name="password" placeholder="password" />
- <button class="btn" type="submit">Login now!</button>
- </form>
- </div>
- </div>
- </div>
- <div class="container">
- <div class="content">
- <div class="page header">
- Page header!
- </div>
- <div id="registration_form">
- </div>
- if(//some of the data in the form isn't set)
- {
- //Set error conditions based on missing data
- }
- $confirm_password=$_REQUEST['confirm_password'];
- $password=$_REQUEST['password'];
- if($confirm_password != $password){
- //report passwords don't match}
- $email_addr=$_REQUEST['email_addr'];
- $first_name=$_REQUEST['first_name'];
- $last_name=$_REQUEST['last_name'];
- try
- {
- $successful_creation=create_user_and_send_verification_email($email_addr, $password, $first_name, $last_name);
- }
- catch(Exception $e)
- {
- /*SQL errors are caught here*/
- }
- if($successful_creation==FALSE)
- {
- //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?
- }
- else
- {
- //redirect to a "wait for a verification email" page
- }
Add Comment
Please, Sign In to add comment