Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'ch09'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello I've finished chapter 9 and am currently attempting to create a registration form on the site using HTML_QuickForm2. Everything is working fine, except I can't seem to return error messages if the username and/or email address are already registered. Here is the code after the form has been submitted: // Add the submit button if($_SERVER['REQUEST_METHOD']=='POST'){ $errors = array(); // validate the form data if($form->validate()){ //check to see if the email is available $select_query = 'SELECT id FROM users WHERE email=:email or username=:username'; $stmt = $pdo->prepare($select_query); $select_result = $stmt->execute(array(':email'=>$email->getValue(), ':username'=>$username->getValue())); // Check to see if email address is available if(mysqli_num_rows($select_result)==0){ // if the email address or username are available // Insert the user into the database $insert_query = 'INSERT INTO users (userType, username, email, pass, dateAdded) VALUES (:userType, :username, :email, SHA1(:password), NOW())'; $stmt = $pdo->prepare($insert_query); $insert_result = $stmt->execute(array (':userType'=>'public', ':username'=>$username->getValue(), ':email'=>$email->getValue(), ':password'=>$password->getValue(), )); if($insert_result){ // if it ran ok // freeze the form upon success $form->toggleFrozen(true); $form->removeChild($submit); } else { $errors[] = ('You could not be registered at this time'); } } else { // if the username/password are already registered $errors[] = ('The username and/or password have already been registered.'); } } } The problem is that only the error message in the 'insert_result' else statement is displayed when I loop through the results in the register.html view. Any other errors added to the array are not displayed, so the user is not notified why they can't register. Is this a problem with the way I'm trying to implement it (objects instead of procedurally) or is there something obvious that I've missed? Hope I've explained myself well and thanks in advance for any suggestions.
×
×
  • Create New...