looking for form script with redirect capability

Discussion in 'PHP' started by mcdc2000, Nov 28, 2006.

  1. #1
    hello,

    looking for php form script with redirect pages features.
    also need to capture data into either txt file or mysql database.

    when user input info, like name, email, address, etc..
    and several options like link1, link2, link3..
    and click submit.

    script need to capture info like name, email, address into mysql database
    and depends on options that user choose,
    if link1, need to redirect to url1
    if link2, need to redirect to url2
    if link3, need to redirect to url3.

    anybody know this kind a script?
    I'm looking for free script.

    Mike
     
    mcdc2000, Nov 28, 2006 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That's easy to do in php. It shouldn't take more than 15 minutes to create a working version.
     
    maiahost, Nov 28, 2006 IP
  3. mcdc2000

    mcdc2000 Peon

    Messages:
    157
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    so, do you have working version that I can try
     
    mcdc2000, Nov 28, 2006 IP
  4. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    A quick and dirty version :
    
    <?php
    $add=$_POST['add'];
    $name=$_POST['name'];
    $redirect=$_POST['redirect'];
    //connect to db first - this is a sample query
    mysql_query("insert into users (`id`,`name`) values ('','$name');");
    if($redirect)
    {
    header('Location: '.$redirect.'');
    }
    ?>
    <form name="form3" action="2.php" method="post">
    <table width="95%"  border="0">
    <tr>
    <td width="20%">Your Name </td>
    <td><input type="text" name="name" /></td>
    </tr>
    <tr>
    <td><span class="style6">Redir</span> </td>
    <td><select name=redirect>
    <option value="http://www.msn.com" selected>Msn</option>
    <option value="http://www.google.com">Google</option>
    <option value="http://www.yahoo.com">Yahoo</option>
    </td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" class="formbox" name="Submit" />
    <input type="hidden" name="add" value="1">
    </td>
    </tr>
    </table>
    </form>
    
    
    
    PHP:
     
    maiahost, Nov 28, 2006 IP
  5. Juls

    Juls Well-Known Member

    Messages:
    1,867
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    170
    #5
    this will only redirect but not based on the link selection.

     
    Juls, Nov 28, 2006 IP
  6. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Works just fine here :)
     
    maiahost, Nov 28, 2006 IP
  7. Juls

    Juls Well-Known Member

    Messages:
    1,867
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    170
    #7
    lol sorry my bad totally disregarded the variable in the header call ;-)

    good stuff maiahost.

    here i was throwing in a switch.
     
    Juls, Nov 28, 2006 IP
  8. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #8
    No problem at all - hope this helps to the thread starter - By the way this was taken from a website of mine so there's some extra code (class="formbox") etc that you can remove.
     
    maiahost, Nov 28, 2006 IP