Jump to content


Photo

How to put 2 links in submit button


  • Please log in to reply
4 replies to this topic

#1 luvburn

luvburn
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 27 September 2006 - 05:05 AM

Hi...i have this problem of linking 2 pages from one button. Let say i have 3 pages. I want to send the values from page 1 to page 2 and 3.

This the code for page 1 which i set the action to go to page2
<?php 
<form name="form1" method="get" action="page2.php">
<table width="585" align="center">
<tr>
<td>Umur :</td>
<td ><input type="radio" name="umur" value="1"> < 1 tahun</td>
<td ><input type="radio" name="umur" value="2" >1 - 10 tahun</td>
<td><input type="radio" name="umur" value="3" > 11 - 19 tahun</td>
<td ><input type="radio" name="umur" value="4" >  19 tahun</td>
</tr>
</table>
<input type="submit" name="submit" value="Teruskan" >

</form>	

?>

I can simply get the values at page2 by using $_GET. How do i do the same action to page 3 by clicking the submit button and retrieving the same values so that whenever i go to page3 the values from page1 is already there.
Where should i put the link?



#2 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 27 September 2006 - 05:16 AM

Hej
  Use sessions?

page one has
session_start();
$_SESSION["data1"]=$data1;


and

page three has
session_start();
$data1 = $_SESSION['data1'];

WW

#3 mitzleah

mitzleah
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationManila, Philippines

Posted 27 September 2006 - 05:17 AM

use session variables instead of get variables

#4 luvburn

luvburn
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 27 September 2006 - 07:37 AM

The session is not working. Somehow i want to use the values in page2. So i use $_GET to get the values from page 1 using the URL links. After that i want to send the values to page3.
Page 2 has a lot of server side functions. The values only appear for the first time we view the page but
lost each time some of those functions operated. So how do i hold the values from page1 no matter functions operated in page2.

this the code in page 2

<?php

include ('mysql_connect.php');
include ('papar_fungsi.php');

session_start();
session_name ('diagnos');


  $_SESSION['age'] =  $_GET["umur"];
  $_SESSION['sex'] = $_GET["jantina"];
  $_SESSION['race'] = $_GET["kaum"];
?>
<form name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
:
  $_SESSION['age'] ....
(a lot of php function here)
?>
</form>

<?php	   
echo "<a href=\"senarai_simptom.php?a=$age\">Simptom</a> " ;
 ?>


I want the values to be send after clicking the 'Simptom' link but as i said before, the values lost before i can send to page3.

#5 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 27 September 2006 - 07:50 AM

Hej,
  If sessions are not working for you
  && you are using a form on both page 1 and page 2
  && and you need data passed from page 1 to go to page 3

then

  use input type="hidden" fields to pass data along.
 
 
 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users