www.webdeveloper.com
Results 1 to 3 of 3

Thread: Error message positioning

  1. #1
    Join Date
    Feb 2012
    Posts
    2

    Question Error message positioning

    Please help me!

    I want to know the code to simply showing the error message beside the textbox in which the error take place. For example: in registration form, when the user input a username that is already exist, i want to show the error message "The username you entered already exist" beside the username textbox
    hope you get what i want to point out. Thanks in advance.

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    Multiple ways to do this. Simplest would be just to spit out the error when postback occurred

    PHP Code:
    <?php
    $error 
    null;
    if(isset(
    $_POST['my_post_check'])){
      
    $username clean_string($_POST['username']);
      
    $query sprintf("SELECT 1 FROM `users` WHERE `username` = '%s'"$username);
      
    //... etc
      // If exists
      
    $error 'Error message';
    }
    ?>

    <input name="username" type="text" /><?php !empty($error) ? $error '' ?>

  3. #3
    Join Date
    Feb 2012
    Posts
    2
    Thanks @ssystems i solved the problem already. More power to you. Cheers!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles