Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PASSING VARIABLES

Status
Not open for further replies.

dadms

Technical User
Mar 8, 2003
67
0
0
US
I need help passing variables. When I do a print I see the variable display but when I try to use it my update statement dont work.

starts with page 1 I use:
print ("<td valign='top' bgcolor='$row_color'><font size='2'><a href=lginfrm1.php?logid=$variable1>$variable1</a></td>");

this brings up lginfrm1.php fine. I then have an option to make a change and update. When I make the change and select update the changes dont save.

?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="logid" value="<?php echo $logid ?>">

<?php
if ($submit) {
$sql = "UPDATE logins SET compl='$compl' WHERE logid='$logid'";
$result = mysql_query($sql);

If I manually set $logid=2 (or to any number)then the update will take place.
 
Hi,

I belive the internal quotes are the problem, try normal parentheses.

Code:
[red]$sql = "UPDATE logins SET compl='$compl' WHERE logid='$logid'";[/red]

[green]//CHANGE TO THIS[/green]

[blue]$sql = "UPDATE logins SET compl=[red]\"[/red]$compl[red]\"[/red] WHERE logid=[red]\"[/red]$logid[red]\"[/red]";[/blue]

~Good Luck,
Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
nah, the quotes are fine. How are you setting the following variables:

[&raquo;] $submit
[&raquo;] $compl
[&raquo;] $logid


*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
$logid should come from the previous page and insert into a hidden field (this is the part thats broke)however I can print it and get the value on the page.

<input type=hidden name="logid" value='<?php echo $logid ?>'>



$submit comes from my input button

<td><input type="Submit" name="submit" value="UPDATE RECORD">

$compl comes from an input field (and carried over variable)
<INPUT TYPE="TEXT" name="compl" size="1" maxlength="1" value="<?php print $variable21 ?>"</td>

$variable21=$row["compl"];

$logid should come from the previous page and insert into a hidd field (this is the part thats broke) I can print it and get 2

<input type=hidden name="logid" value='<?php echo $logid ?>'>



 
The way to reference variable submitted on a previous page from a form is as follows:

If the form uses the "GET" method:
[tt] $logid = $_GET['logid'];
$compl = $_GET['compl'];[/tt]

If the form uses the "POST" method:
[tt] $logid = $_POST['logid'];
$compl = $_POST['compl'];[/tt]

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Thanks for all the help...

Dont know why all of a sudden it works but here is the code from the page...

<input type=hidden name="logid" value='<?php echo $logid ?>'>
 
You have register globals set to on, perhaps someone got wise and turned them off on you, but now they're back on?

That or you're using the export function.

Either the way, you should be very careful with this, especially if it's an external facing page, it's a significant security risk.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top