SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot .[:] : paVel : [:].'s Avatar
    Join Date
    May 2002
    Location
    Australia
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :::::::: checking data......?

    Hey.
    I have a form with lots of fields...
    How can i check them and then display the result... like
    username...ok
    password...ok
    e-mail...error!

    ?????

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would do it like this:
    PHP Code:
    <?php
    while (list($key$val) = each($_POST)) {
        echo 
    $key"...";
        if (
    $val != "") {
            echo 
    "ok";
        } else {
            echo 
    "error!";
        }
    }
    ?>
    That will check if they are empty or not but you can probably edit the code to check like a database or something.
    - the lid is off the maple syrup again!

  3. #3
    SitePoint Zealot .[:] : paVel : [:].'s Avatar
    Join Date
    May 2002
    Location
    Australia
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can someone PLZ expain it to me more clearly?

  4. #4
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use this:
    PHP Code:
    <?php
    while (list($key$val) = each($_POST)) {
        echo 
    $key"...";
        if (
    $val != "") {
            echo 
    "ok.<br>";
        } else {
            echo 
    "error!.<br>";
        }
    }
    ?>
    It will get all the values for $_POST or $_GET whichever one you use and lists them in a while loop. Then it checks the value for it and if the value is not empty it will print ok, otherwise it prints error!. So like this would be your output if they were all filled in except one.
    Code:
    username...ok.
    password...ok.
    email...error!.
    - the lid is off the maple syrup again!


Bookmarks

Posting Permissions

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