Results 1 to 2 of 2

Thread: Input Type = Multiple Radio redirect

  1. #1
    Join Date
    Feb 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Input Type = Multiple Radio redirect

    Just wondering how to go about this...

    I have 3 radio buttons on a site and depending on which radio button is selected I want it to redirect upon submit to one of three web pages.

    such as:
    Code:
    <?PHP
    
    if (isset ($POST[submit1])) {
    
      $which_site = "x,y,z"
         if x then 1.php
         else if y then 2.php
         else if z then 3.php
    
    }
    ?>
    
    <body>
    <form name ="sites" method ="post" action = "$which_site">
    <input type ="radio" name ="sites" value ="#">Site 1
    <input type ="radio" name ="sites" value ="#">Site 2
    <input type ="radio" name ="sites" value ="#">Site 3
    <input type ="submit" name ="submit1" value ="Submit">
    </form>
    Yes I know this would be easier to do with just straight html, but it will help me learn more further along in building other pages for this site. I will later be building more php code that will redirect to a webpage with form output information being pulled from a database. Yes I also know the code above is no where near correct it's just an example of what I think it may look like.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    PHP Code:
    <?php
    if (isset ($_POST['sites'])) {
        
    header('Location: ' $_POST['sites']);
    }
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Switch to Location</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    </head>
    <body>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="radio" name="sites" value="http://www.google.com/">Site 1
    <input type="radio" name="sites" value="http://www.dynamicdrive.com/">Site 2
    <input type="radio" name="sites" value="http://en.wikipedia.org/wiki/Main_Page">Site 3
    <input type="submit" value="Submit"><br>
    <p><input type="reset"></p>
    </form>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •