SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I forward a string from a drop down menu to another page?

    How do I get a value which is selected from a drop down menu to another web page?

    I've been trying to get it into a $_SESSION but really struggling.

    The drop down menu works a treat now, getting the values from a mysql database. But when I click on a value, it'll go to the webpage designated but doesn't make the value with it?!? If that makes sense?

    This is my code so far.

    PHP Code:
    <?php
    session_start
    (); 
    if(
    $_SESSION['login'] != 'Logged') { 
    header("Location: index.php"); 
    }

    // OPEN THE DATABASE CONNECTION
    $conn=mysql_connect ("localhost""user""password") or die ('I cannot connect to the database because: ' mysql_error());

    // PICK THE DATABASE TO USE
    mysql_select_db ("database",$conn); 

    // SELECT DATA FROM DATABASE
    $query="SELECT * FROM clinician";
    $result=mysql_query($query);

    $num=mysql_numrows($result);

    mysql_close();

    $i=0;
    $myoptions "";
    while (
    $i $num) {
     
    $clinician_pin=mysql_result($result,$i,"pin");
     
    $myoptions .= "<option value=\".$clinician_pin.\">"$clinician_pin ."</option>\r\n";
    $i++;
    }    

    // CHECK IF THE FORM IS SUBMITTED
      
    if(isset($_POST['clinician_pin']))
      {               
      if (
    false === $clinician_pin)
      
    // DEFINE SESSION VARIABLES
         
          
    $_SESSION['clinician_pin'] = $_POST['clinician_pin'];

          
    // REDIRECT
              
    header('Location: clinician_checks2.php');
              exit;
                    }
    ?>

    <html>
    <body bgcolor="#99CCFF">
    <p align="center"><font size="7" face="Arial Narrow">WMAS - </font><i><b><font size="7" face="Papyrus">mk</font></b></i><font size="7" face="Arial Narrow">
    PORTAL</font></p>
    <p align="center"><font size="6">Wolverhampton</font></p>

    <p align="center"><font size="4" face="Arial">PRF Checks - by Clinician</font></p>
    <p align="center"><font face="Arial">Please select Clinician by PIN number&nbsp;</font></p>

    <form name="submit_data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <p align="center">
      <select size="1" name="clinician_pin"><?php echo $myoptions?></select>&nbsp; 
      <input type="hidden" name="submit_form">
      <input type="submit" name="submit" value="submit" label="submit">

    </form>

    </body>

    </html>

    I suspect it's something to do with this section but not exactly sure what it's doing?!

    PHP Code:
    // CHECK IF THE FORM IS SUBMITTED 
      
    if(isset($_POST['clinician_pin'])) 
      {                
      if (
    false === $clinician_pin
       
    // DEFINE SESSION VARIABLES 
          
          
    $_SESSION['clinician_pin'] = $_POST['clinician_pin']; 

           
    // REDIRECT 
              
    header('Location: clinician_checks2.php'); 
              exit; 
                    } 

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $url "clinician_checks2.php?pin=" $_POST['clinician_pin'];
    header("Location: " $url); 

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not exactly what I wanted - I have no idea how to use the value when it's in the url ??

    I was hoping that it could be stored in a $_string so I can use it within the code of the redirected webpage.

  4. #4
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman
    PHP Code:
    $url "clinician_checks2.php?pin=" $_POST['clinician_pin'];
    header("Location: " $url); 
    On the page clinician_checks2.php, you would access the pin via:

    $_GET['pin']

    To get the variables passed in the URL (called the query string) you use $_GET as an array where the name (the part before the =) is the array index.


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
  •