session variable gets value when clocked on url
Moderator: General Moderators
session variable gets value when clocked on url
Hi,
I have a page that returns a resultset of a query I made to mySQL db. There is a certain field in the results that has to be clickable so I can then go to a page with more detail of that certain record. I know I can put the value I want to send to the next page in the URL and then just use it, but I don't want to send info in the URL.
How do I assign a session variable with a value depending on which record's field URL I click? I've spent almost 6 hours on the net already trying to find a solution...
I'm using PHP 4.3.6 on IIS 5 with WinXP.
Any help will be appreciated
I have a page that returns a resultset of a query I made to mySQL db. There is a certain field in the results that has to be clickable so I can then go to a page with more detail of that certain record. I know I can put the value I want to send to the next page in the URL and then just use it, but I don't want to send info in the URL.
How do I assign a session variable with a value depending on which record's field URL I click? I've spent almost 6 hours on the net already trying to find a solution...
I'm using PHP 4.3.6 on IIS 5 with WinXP.
Any help will be appreciated
I'm usgin PHP in Dreamweaver MX... How do I post the form back to the script in Dreamweaver?
Here's the code with the repeat region on the records where the hyperlink also is...
<?php while ($row = mysql_fetch_assoc($ClientSearch)) { ?>
<tr bgcolor="#C1D8E6">
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="AdminClientInfoPolicy.php?IDNumber=<?php echo $row["IDNumber"]; ?>"><?php echo $row["Surname"]; ?></a></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["Initials"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PostalAddrTown"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneHome"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneBus"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneCell"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["Broker"]; ?></font></div></td>
</tr>
<tr>
<td> </td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
</tr>
<?php } ?>
Here's the code with the repeat region on the records where the hyperlink also is...
<?php while ($row = mysql_fetch_assoc($ClientSearch)) { ?>
<tr bgcolor="#C1D8E6">
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="AdminClientInfoPolicy.php?IDNumber=<?php echo $row["IDNumber"]; ?>"><?php echo $row["Surname"]; ?></a></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["Initials"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PostalAddrTown"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneHome"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneBus"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["PhoneCell"]; ?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row["Broker"]; ?></font></div></td>
</tr>
<tr>
<td> </td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"> </font></td>
</tr>
<?php } ?>
Change the href to:
then add a function to the page that will do the form-based stuff:
Then, finally, put a form in the document:
And that'll do it
You might want to ensure the javascript works on every platform you want it to...
Code: Select all
javascript:adminClientInfoPolicy("<?=$rowї"IDNumber"];?>");Code: Select all
<script language="javascript>
function adminClientInfoPolicy(id) {
document.formname.IDNumber.value=id;
document.formname.submit();
}
</script>Code: Select all
<form name="formname" method="post">
<input type=hidden name="IDNumber">
</form>
Last edited by dave420 on Tue May 18, 2004 11:40 am, edited 1 time in total.
This hyperlink works now. Another problem is now one of leading zero's being thrown away by the function...
The value of
in
sometimes is something like 0020956799. But when it assign this value to the hidden field and it gets submitted, the value changes to 20956799. All the leading zero's are discarded, and suddelny the results on the next page can't display correctly, because the IDNumber isn't identical to the one that is actually needed there. And also I'm assigning this value to a $_POST['IDNumber'] variable in the next page. Don't know if this has something to do with it.
Is there a way to assign this value to the hidden field so that the identical string gets sent and assigned to the $_POST variable in the next page?
Regards
The value of
Code: Select all
<?=row["IDNumber"];
?>Code: Select all
javascript:adminClientInfoPolicy("<?=$rowї"IDNumber"];?>");Is there a way to assign this value to the hidden field so that the identical string gets sent and assigned to the $_POST variable in the next page?
Regards
The problem isn't there. It send the correct value to the adminClientInfoPolicy(id) function in the 6'th post. It throws away the zero's when I do this in that function
Code: Select all
document.formname.IDNumber.value=id;
document.formname.submit();