Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Verification Form

    Hi,

    I am interested in making a page where it has a text box and a Submit button. And if the ext that is entered is correct, it redirects to another page. If it is wrong, it redirects to an error page.

    I have this code so far:

    Code:
    <?
    if ($question)
    {
       if ($question=='DevsDancin, devsdancin, ladybug070, Ladybug070')
       {
            header("Location: fullurlofpage")
       }
       else
       {
           header("Location: fullurlofwrongpage");
       }
    }
    ?>
    Can you please help me out?

    Thanks, th3gh05t

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome here !

    Your explanation is rather vague so i might be off here.
    Supposing that the textbox is called 'test' and the you post the form using the postmethod, and that the complete value of $_POST['test'] needs to be one of the values from $question, then you'd have
    PHP Code:
    <?php
    $question
    = array('DevsDancin''devsdancin''ladybug070''Ladybug070');
     if (
    in_array($_POST['test'],$question)){
        
    header('Location: fullurlofpage')
    } else {
        
    header('Location: fullurlofwrongpage');
    }
    ?>
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.

    But where do I put that code?

    I have this so far:

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    </head>
    <?php
    $question= array('DevsDancin', 'devsdancin', 'ladybug070', 'Ladybug070');
     if (in_array($_POST['test'],$question)){
        header('Location: fullurlofpage')
    } else {
        header('Location: fullurlofwrongpage');
    }
    ?> 
    <body>
    <form name="form1" method="post" action="">
      <input name="test" type="text" id="test">
      <input type="submit" name="Submit" value="Submit">
    </form>
    </body>
    </html>

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php
    $question
    = array('DevsDancin''devsdancin''ladybug070''Ladybug070');
     if (
    in_array($_POST['test'],$question)){
        
    header('Location: fullurlofpage')
    } else {
        
    header('Location: fullurlofwrongpage');
    }
    ?> 
    <html>
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    <form name="form1" method="post" action="">
      <input name="test" type="text" id="test">
      <input type="submit" name="Submit" value="Submit">
    </form>
    </body>
    </html>
    Headers have to be before any output to the browser, which includes html

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get this error:

    Parse error: parse error in /home/drossler/www/test.php on line 5

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Missing semi-colon at the end of this line

    header('Location: fullurlofpage');

  • #7
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok. This is what I have now. When I load up the page, there are no errors, and when I enter a value into the text box and hit Submit, nothing happens. The text gets cleared, and looks like the page reloads.

    PHP Code:
    <?php
    if ($question)
    {
    $question= array('DevsDancin''devsdancin''ladybug070''Ladybug070');
     if (
    in_array($_POST['test'],$question)){
        
    header('Location: http://www.google.com');
    } else {
        
    header('Location: http://news.google.com');
        }
    }
    ?> 
    <html>
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    Enter AIM Name: <br>
    <form name="form1" method="post" action="">
      <p>
        <input name="test" type="text" id="test">
        <input type="submit" name="Submit" value="Submit">
        <br>
        <i><font color="#FF0000">*case senstive.</font></i>
    </p>
    </form>
    </body>
    </html>
    Last edited by th3gh05t; 04-21-2004 at 08:24 PM.

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Change this line:
    PHP Code:
    if ($question
    to
    PHP Code:
    if (isset($_POST['Submit'])) 

  • #9
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And also put the name of the page you are making in the action="" spot


  •  

    Posting Permissions

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