SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast devAngel's Avatar
    Join Date
    Sep 2005
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php validation with redirect

    Hi guys,

    I was wondering if there's a way when a user clicks on a submit button on a form, it would validate the fields then if all fields are filled out, it would redirect to another page. I have been searching and trying different scripts but it doesn't work...I figured you guys could help me out on this one...

    p.s i tried to search it here as well but haven't find answers yet

    Thanks in advance...
    sig space open...

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    <?php
    ## processform.php
    
    if ($_POST['inputfield1'] == "validation") {
        header("Location: /validated.php");
    } else {
        header("Location: /invalid.php");
    }
    ?>

  3. #3
    SitePoint Enthusiast devAngel's Avatar
    Join Date
    Sep 2005
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'll try that...thanks!
    sig space open...

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's also good practice to use the exit function when using the header function to redirect.
    PHP Code:
    header("Location: /validated.php");
    exit; 


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
  •