I am a new user in PHP programming. I am having problems passing variable(s) from one page to another using html fill-in Forms. Could someone help me on this
###----- below is my input part of the program
<?include("odbcconnection.phtml"); ?>
<?
global $PINA;
if ($RedirectAction=="Open")
{
$QueryID = "Select * from usertable Where userid = '$userid' and password = '$userpassword'";
if (!($Result = odbc_do($odbc_db, $QueryID)))
die ("Error in SQL");
// use this for odbc connection, other database use the block below
$cols = odbc_num_fields($Result);
while (odbc_fetch_row($Result))
{
for ($a =1; $a <= $cols; $a++)
{
// $checking = 1;
$data = odbc_result($Result, $a);
}
}
if ($data == "")
{
$Cancel = 1;
}
$PINA = $userid;
}
?>
<?
if (($RedirectWhere<>"")&&($Cancel==""))
{
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=".$RedirectWhere."'>";
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Untitled</title>
</head>
<script>
function Redirect(Where, Act)
{
document.forms[0].RedirectWhere.value = Where;
document.forms[0].RedirectAction.value = Act;
document.forms[0].submit();
}
</script>
<!--- ### Form starts here #### --->
<body bottommargin=0 topmargin=0>
<form method="POST" action="open.phtml">
<input type="hidden" name="RedirectWhere" value="<?echo $RedirectWhere?>">
<input type="hidden" name="RedirectAction" value="<?echo $RedirectAction?>">
<TABLE WIDTH="600" BORDER="0" ALIGN="center">
<TR>
<td align="center"> Login Form
</td>
</tr>
<tr>
<td align="center"><input TYPE="text" NAME="userid" SIZE="8"> <BR>
<input TYPE="password" NAME="userpassword" SIZE="8">
<?
if ($Cancel==1)
echo "<BR><tr><td ALIGN='center'><font color='red' face='verdana' size='2'> Please try again </font></td></tr>";
?>
</td>
</tr>
<tr>
<td align="center"><input type="submit" name="Open" value="Open" Onclick="Redirect('second.phtml', 'Open')"> <input type="submit" name="Back" value="Back" OnClick="Redirect('open.phtml', 'Back')"></td>
</tr>
</table>
</form>
</body>
<?include("odbcloseconn.phtml")?>
end here
second page is the response from the above pprogram (FORM)
Start here ####
<?
include("odbcconnection.phtml");
if (!$PINA)
{
echo "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=open.phtml'>";
exit;
}
$query = "Select * from usertable Where userid = '$userid' and password = '$userpassword'";
print $PINA;
?>
end
Thank you very much