Forum Moderators: coopster

Message Too Old, No Replies

passing var in URL to next page using form POST

passing var in URL to next page using form POST

         

knippysing

1:56 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Hello friends,
Need a bit of assistance... I'm trying to pass data that is sent to the URL using GET but my only problem is, it needs to pass through a form using POST (for security).
?var=something is already in the address bar when at the security login... I need to get that onto the next page, whatever that page may be.

The security page code on Page 1 is as follows:
________________________________________
<form action='<?PHP echo $documentLocation;?>' METHOD="post" onSubmit="return checkData()">
<TABLE WIDTH="100%" HEIGHT="100%" CELLPADDING="0" CELLSPACING="0"><TR><TD ALIGN="center" VALIGN="middle">

<TABLE <?PHP echo $theTable;?> CELLPADDING="0" CELLSPACING="0" BACKGROUND="<?PHP echo $cfgHtmlDir;?>images/<?PHP echo $bgImage;?>"><TR><TD ALIGN="center" VALIGN="middle">
<TABLE CELLPADDING="4" WIDTH="100%" HEIGHT="100%" BACKGROUND="">
<TR><TD ALIGN="center" COLSPAN="2"><h1><?PHP echo $strLoginInterface;?></h1></TD></TR>
<TR><TD ALIGN="center" COLSPAN="2">
<B><I><NOBR><?PHP
// check for error messages
if ($message) {
echo $message;
}?></NOBR></I></B>
</TD></TR>
<tr><TD VALIGN="bottom"><A HREF="<?PHP echo $cfgUrl . getenv("HTTP_HOST") . $cfgIndexpage;?>" TABINDEX="2">
<IMG SRC="<?PHP echo $cfgHtmlDir;?>images/cancel.gif" ALIGN="left" WIDTH="22" HEIGHT="23" ALT="<?PHP echo $strCancel;?>" BORDER=0 hspace=10 vspace=4></A>
</TD>
<td ALIGN="right" VALIGN="bottom">
<table cellpadding=4 cellspacing=1 BACKGROUND="">
<tr><td><B><FONT FACE="Arial,Helvetica,sans-serif" SIZE="-1"><?PHP echo $strLogin;?>: </FONT></B></td>
<td> <INPUT TYPE="text" NAME="entered_login" STYLE="font-size: 9pt;" TABINDEX="1"></td></tr>
<tr><td><B><FONT FACE="Arial,Helvetica,sans-serif" SIZE="-1"><?PHP echo $strPassword;?>: </FONT></B></td>
<td> <INPUT TYPE="password" NAME="entered_password" STYLE="font-size: 9pt;" TABINDEX="1"></td></tr>
</table>
<INPUT TYPE=image src="<?PHP echo $cfgHtmlDir;?>images/enter.gif" WIDTH="26" HEIGHT="23" border=0 hspace=7 vspace=4 alt="<?PHP echo $strEnter;?> &gt;&gt;&gt;" TABINDEX="1">
</td></tr></table>
</TD></TR></TABLE>
</TD></TR></TABLE>

</form>
__________________________________________
The page it's being sent to needs the var in there to display the correct data.
The code on the next page (page 2) is as follows:
______________________
<?PHP
$requiredUserLevel = array(1);
$cfgProgDir = 'SecurityCheck/';
include($cfgProgDir . "secure.php");
?>
________________________

How do I get that darned?var=something to post on Page 2s Address Bar?

Thanks in advance!

HeadBut

2:20 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Would this work:
<form action='<?PHP echo $documentLocation;?>?var=<?PHP echo $yourVar;?>' METHOD="post" onSubmit="return checkData()">

Just a guess

turock

3:18 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Why not pass the needed variable as a hidden form input. <input type='hidden' name='var' value='$var'>. Then on the page that you need to retreive the variable use $var = $_POST['var'];

knippysing

3:23 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Then how to I get the $var into the addressbar on the page 2?

I'm getting close...

The first try/answer gave me a?var= in the address bar but didn't carry over what was sent before... (i.e.?var=SalesCrosstab.Invoice)

is there a way to edit
?var=<?PHP echo $yourVar;?>
so that I grab what's after?var= currently in the addressbar? i.e. GET?

knippysing

3:49 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



I think I got it...

$var = @$_GET['var'] ;

In my globals... Then used the function Headbut suggested using $var. Looks like it's passing just fine now.

Thanks to all of you for your fine help! Always a pleasure.

HeadBut

3:54 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Try this:

<form action='<?PHP echo $documentLocation;?>?var=<?PHP echo $_GET['yourAddressBarVar'];?>' METHOD="post" onSubmit="return checkData()">

Personallay I would do this:

if(ISSET($_GET['youraddressbarVar'])){$Var = addslashes($_GET['youraddressbarVar']);}elseif(ISSET($_POST['YourFormVar'])){$Var = addslashes($_POST['YourFormVar']);}else{$Var = "DefaultValue";}
....
...<Form XXXXXXX>
<INPUT Type="hidden" Name="var" Value="<?PHP echo $Var;?>">

Hope this is helpfull

knippysing

4:01 pm on Jun 23, 2005 (gmt 0)

10+ Year Member



Cool! This worked as well.

Thanks again! Once you stop learning... you're dead.