Results 1 to 8 of 8

Thread: How to use $_GET in multiple page

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to use $_GET in multiple page

    Hi..guys!I have a 3 different pages here.Ihave submitted some data in the first page and display them in second page by echoing $_GET['x'].However why I can't use back $_GET['x'] to display the same thing in third page?
    What might be changed in order value can be displayed in third page?Thanks..

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would need to pass those variables along to the next page in order for it to work. On the second page; where you echo the $_GET['x'], you would need to pass that to the next page in the url like so:

    Code:
    page.php?x=<?php echo $_GET['x'];?>&amp;next=another_var
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks.So how can I coded it at here?
    Code:
    <td>
    <?php echo $_GET['selected_date'];?>&amp;next=another_var;?>
    </td>

  4. #4
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Let said I still have 3 values in second page need to be sent to third page,how can join up with the previous one which passed from first to second page?

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well; if you are using forms in those pages, you could simply make a hidden field with that name/value pair. Something like so:

    Code:
    <input type="hidden" name="x" value="<?php echo $_GET['x'];?>">
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry.It is quite complex for my form because several values need to pass to third page from first and second page?Can you help me to find out where to insert the right code?

    reservation.php(first page)

    Code:
    <?php
    include ('dbconn.cfg'); // database configuration file
    $connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
    session_start();
    //if (isset($_POST['continue'])) {
        //include_once ('reservation2.php');
    //}
    
    //$_SESSION['n'] = @$_SESSION['n']+2;
    //include('reservation'.$_SESSION['n'].'.php');
    ?>
    
    <?php
    if(!(isset($_SESSION['gmemberid']))){
      $redirectUrl = "http://localhost/www2/loginReq.html";
      print "<script type=\"text/javascript\">";
      print "window.location.href = '$redirectUrl'";
      print "</script>";	
    }
    ?> 
    
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Blue Projection - Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    
    function validateDrop(date)
    {
    	var returnStatus = 1;
    
        if (date.rDate.selectedIndex == 0) { //if user didn't select any date
    		alert("Please select a date!");
    		returnStatus = 0;
    	};
           
    	if (returnStatus) { // if date is selected
    		window.location='reservation2.php'
    	}
    }
    
    function GoToNextPage(value){
      if(value != ""){
           document.location = 'reservation2.php?selected_date=' + value;
           //document.location = 'reservation3.php?selected_date=' + value;
      }
    }
    </script>
    </head>
    
    <body>
    <table width="80%" height="557" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6y-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="3%">&nbsp;</td>
        <td width="97%" height="222"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%" height="29"><font color="#0000FF" size="+2" face="Arial">Online 
                Reservation</font></td>
               <?
    if (isset($_SESSION['gmemberid'])) {
    ?>
     <td><b><font color="blue">Logged in as: <? echo $_SESSION['gmemberid']; ?></font></b></td><br><br>
    <? } ?>
            </tr>
            <tr> 
              <td height="21" colspan="2"><div align="left"><img src="images/line2.JPG" width="750" height="4"></div></td>
            </tr>
            <tr> 
              <td height="60" colspan="2"> <p><font face="Arial">To begin, please 
                  select the date.<br>
                  Only tickets for three days ahead can be reserved</font><font face="Arial">.<br>
                  </font></p></td>
            </tr>
            <tr> 
              <td height="106" colspan="2"><form action="reservation2.php" method="get"
    		      name="reservation" id="reservation">
                  <table width="100%" border="0">
                
                    <tr> 
                       <td width="21%"><font face="Arial"> 
                        <label>Date:</label>
                        &nbsp;</font></td>
                      <td width="79%"><font face="Arial"> 
                          <select name="rDate" onChange="GoToNextPage(this.value)">
                          <option selected> Select</option>
                          
                          //dynamic display of date 
                          <?php for ($i = 1; $i <= 3; $i++) {
                          $date = date('D d\t\h M', strtotime('+' . $i . ' days'));?>
                          <option value="<?=$date;?>"><?=$date;?></option>
                          <?php } ?>
                          </select>
                         </font></td>
                    </tr>
                 
                    <tr> 
                      <td height="44">&nbsp;</td>
                      <td><font face="Arial"> <br>
                        <input name="continue" type="button" id="continue4" value="Continue" onclick="validateDrop(document.reservation)">
                        </font></td>
                    </tr>
                  </table>
                </form></td>
            </tr>
            <tr> 
              <td height="6" colspan="2"><img src="images/line2.JPG" width="750" height="4"></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="3%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
    </body>
    </html>

  7. #7
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    reservation2.php(second page)
    Code:
    <?php
    include ('dbconn.cfg'); // database configuration file
    $connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
    
    session_start();
    //echo 'Your selected date is = ' . $_GET['selected_date'];
    //$_SESSION['my_date'] = $_POST['rDate'];
    //session_unset($_SESSION['n']);
    
    ?>
    
    <?php
    if (!(isset($_SESSION['gmemberid']))) {
        $redirectUrl = "http://localhost/www2/loginReq.html";
        print "<script type=\"text/javascript\">";
        print "window.location.href = '$redirectUrl'";
        print "</script>";
    }
    ?> 
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    
    <title>Blue Projection - Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table, table * {
         margin: 0;
         padding: 0;
         text-align: left;
    }
    </style>
    <script language="JavaScript" type="text/JavaScript">
        function validate(which) {
            var selects = which.getElementsByTagName('select');
            var radios = which.getElementsByTagName('input');
            for(sel = 0; sel < selects.length; sel++) {
                if(selects[sel].options[selects[sel].selectedIndex].text == 'Select') {
                    alert('Please select number of ticket!');
                    return false;
                }
            }
    
            var rselCount = 0;
            for(radio = 0; radio < radios.length; radio++) {
                if(radios[radio].checked) {
                  rselCount++;
                }
            }
    
            if(rselCount == 0) {
               alert('Please select screening time!');
               return false;
            }
            return true;
        }
        
            
       //function GoToNextPage(value){
            //if(value != ""){
           //document.location = 'reservation3.php?selected_no_ticket=' + value                                       +'selected_time=' + value;
      //}
    //}
    
       //function GoToNextPage_time(value){
    	     //if(value != ""){
    	   //document.location = 'reservation3.php?selected_time=' + value;	
    		 	
      //}
    //}
                    
    </script>
    
    </head>
    
    <body>
    <form action="reservation3.php" method="get" name="movieList" 
    		  onSubmit="return validate(this);">
    <table width="80%" height="557" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="3%">&nbsp;</td>
        <td width="97%" height="222"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%" height="29"><font color="#0000FF" size="+2" face="Arial">Online 
                Reservation</font></td>
                <?
    if (isset($_SESSION['gmemberid'])) {
    ?>
     <td><b><font color="blue">Logged in as: <? echo $_SESSION['gmemberid']; ?></font></b></td><br><br>
    <? } ?>
             
            </tr>
            <tr> 
              <td height="21" colspan="2"><div align="left"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></div></td>
            </tr>
    
             
              
                     <tr> 
                       
                      <td><font face="Arial"> 
                        <label>Number of Tickets:</label>
                        </font>
                         <font face="Arial"> 
                         <select name="rNumber" title="number of ticket">
                          <option selected>Select</option>
                          <option>01</option>
                          <option>02</option>
                          <option>03</option>
                          <option>04</option>
                          <option>05</option>
                          <option>06</option>
                        </select>
                        <label><b>**Ticket price RM 9/ticket**</b></label>
                        </font></td>
                    </tr>
            <tr> 
              <td height="40" colspan="2"> <p><font face="Arial">Choose a movie and 
                  its showtime<br>
                  </font></p></td>
            </tr>
            <tr><td><label><b><?= $_GET['selected_date']; ?></b></label></td></tr>
    	    	
                
                
    <?
    if (isset($_SESSION['gmemberid'])) {
    
        $tbl_name = "movie";
        $result = mysql_query(sprintf('SELECT name,classification,screeningTime FROM %s
                 LIMIT 7', $tbl_name)) or die('Cannot execute query.');
    
    
        //$numrow = mysql_num_rows($result);
    
    
        while ($rows = mysql_fetch_assoc($result)) {
            echo '<table width="100%" border="0"><tr><td height="68">
    			      <table width="100%" height="47" border="0">
                       ---------------------------------------------------------------------------------------------------------<br>';
    
            echo '<strong>' . $rows['name'] . ' (' . $rows['classification'] . ')
    			     <br></strong>';
            foreach (explode(',', $rows['screeningTime']) as $time) { ?>
    			<label>
                <input type="radio"  name="time[<?php echo $rows['name']; ?>]"
    			  title ="screening time" value="<?php echo $time; ?>">
    			  
                <?php echo $time; ?>&nbsp;&nbsp;&nbsp;
                </label>
                <?php } ?>
    <?
        }
    
    }
    ?>	
    
        
      <tr> 
      <td><input name="request" type="submit" value="Submit Request">
                        &nbsp;
                        <input name="back" type="button" value="Back"
    					 onclick="window.location='reservation.php'"> </td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                </td>
            </tr>
            <tr> 
              <td height="6" colspan="2"><font face="Arial"><img src="images/line2.JPG" width="750" height="4"></font></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="3%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
    </form>
    </body>
    </html>

  8. #8
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    reservation3.php(third page)
    Code:
    <?php
    //include ('dbconn.cfg'); // database configuration file
    $connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
    
    //session_start();
    $string = $_GET['rNumber'];
    //$name = $_GET[$rows['name']];
    //$screeningtime = $_GET[$time];
    //$date = $_GET['selected_date'];
    //echo 'Your selected date is = ' . $_GET['selected_date'];
    //$_SESSION['my_date'] = $_POST['rDate'];
    //session_unset($_SESSION['n']);
    
    ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Blue Projection Online Reservation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table, table * {
         margin: 0;
         padding: 0;
         text-align: left;
    }
    </style>
    </head>
    
    <body>
    <form action="" method="post" name="reservedShow">
    <table width="80%" height="646" border="0" align="center" bgcolor="#CCCCFF">
      <tr> 
        <td colspan="2"> <div align="center"> 
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="800" height="300">
              <param name="movie" value="flash%20menu/menu2.swf">
              <param name="quality" value="high">
              <param name="LOOP" value="false">
              <embed src="flash%20menu/menu2.swf" width="800" height="300" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
          </div></td>
      </tr>
      <tr> 
        <td width="2%">&nbsp;</td>
        <td width="98%" height="311"> 
          <table width="100%" border="0">
            <tr> 
              <td width="78%"height="29"><font color="#0000FF" size="+2" face="Arial">Online Reservation</font>
    			  <?
    if (isset($_SESSION['gmemberid'])) {
    ?>
     <td><b><font color="blue">Logged in as: <? echo $_SESSION['gmemberid']; ?></font></b></td><br><br>
    <? } ?></td>
            </tr>
            <tr> 
              <td height="6">
    <div align="left"><img src="images/line2.JPG" width="750" height="4"></div></td>
                <table width="100%" border="0">
            </tr>
            <tr> 
              <td height="218"> 
                  <tr> 
                    <td height="35" colspan="2"><font face="Arial"><strong>You have 
                      requested the following movie details</strong></font></td>
                  </tr>
                  <tr> 
                    <td width="18%"><font face="Arial"><strong>Movie Title</strong></font></td>
                    <td width="82%"><font face="Arial"><?php echo $_GET[$rows['name']]?>
    			    </font></td>
                  </tr>
                  <tr> 
                    <td><font face="Arial"><strong>Showtime</strong></font></td>
                    <td><font face="Arial"><?php echo $_GET[$time];?></font></td>
                  </tr>
                  <tr> 
                    <td><font face="Arial"><strong>Date</strong></font></td>
                    <td><font face="Arial">
                    <input type="hidden" name="selected_date" 
    				value="<?php echo $_GET['selected_date'];?>">
    				<?php echo $_GET['selected_date'];?>
    				</font></td>
                  </tr>
                  <tr> 
                    <td><font face="Arial"><strong>No. of Seats</strong></font></td>
                    <td><font face="Arial"><?= str_replace('0', '', $string);?></font>
    				</td>
                  </tr>
                  <tr> 
                    <td height="55" colspan="2"><font face="Arial">To confirm your 
                      request, click &quot;Confirm&quot;.<br>
                      To change any details, click &quot;Back&quot;</font></td>
                  </tr>
                  <tr> 
                    <td height="33" colspan="2"> <font face="Arial"> 
                      <input type="submit" name="submit" value="Confirm">
                      &nbsp; 
                      <input type="button" name="back" value="Back"
    				  onclick="window.location='reservation2.php'">
                      </font></td>
                  </tr>
                </table></td>
            </tr>
            <tr> 
              <td height="22"><img src="images/line2.JPG" width="750" height="4"></td>
            </tr>
          </table></td>
      </tr>
      <tr> 
        <td width="2%" height="25">&nbsp;</td>
        <td>&nbsp; </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    The date need to pass from first to third page.Hoever,movie name and screening time are passed from second to third page.Thanks for generious help...

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
  •