Hi All,
I’ve got a login page that has a form action of $_SERVER[‘PHP_SELF’], so if the password and username are correct, it just goes to the same page (but shows different content).
The page with the form is Downloads_login.php, and I’ve passed a variable with the url to this page:
http://localhost…/Downloads_login.php?client_id=1
I can get to it no problem, but only BEFORE submitting the form. How do I get the variable to carry on to the rest of the page?
I’ve tried hidden and normal textfields and then posted the variable, but I still can’t get it working.
Here is the page:
<html>
<head><title>Your Downloads</title></head>
<body bgcolor=#FFFFFF>
<?php
$client = $_GET['client_id'];
?>
<div align=center>
<form name="form1" method="post" action="">
<input type="hidden" name="client_txt" value="<?php echo "$client" ?>">
</form>
<TABLE WIDTH=500 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD> <IMG SRC='../../Images/header_01.gif' WIDTH=245 HEIGHT=51 ALT=''></TD>
<TD>
<IMG SRC='../../Images/header_02.gif' WIDTH=255 HEIGHT=51 ALT=''></TD>
</TR>
<TR>
<TD>
<IMG SRC='../../Images/header_03.gif' WIDTH=245 HEIGHT=54 ALT=''></TD>
<TD>
<IMG SRC='../../Images/header_04.gif' WIDTH=255 HEIGHT=54 ALT=''></TD>
</TR>
<tr>
<td colspan=2>
<p><b><font face='Arial, Helvetica, sans-serif'> <br>
Downloads<br>
</font></b></p>
</td></tr>
<?php
// Define your username and password
$username = 'user';
$password = 'password';
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<tr><td colspan=2><form name='form' method='post' action='<?php echo $_SERVER['PHP_SELF']; ?>'>
<p><font face='Arial, Helvetica, sans-serif' size='-1'>Please enter your
Username and Password to view your Downloads</font></p>
<table border='0' cellpadding='5' cellspacing='0'>
<tr>
<td><font face='Arial, Helvetica, sans-serif' size='-1'><label for='txtUsername'>Username</label>
</font></td>
<td><font face='Arial, Helvetica, sans-serif' size='-1'>
<input type='text' name='txtUsername' />
</font></td>
</tr>
<tr>
<td><font face='Arial, Helvetica, sans-serif' size='-1'><label for='txtpassword'>Password</label>
</font></td>
<td><font face='Arial, Helvetica, sans-serif' size='-1'>
<input type='password' name='txtPassword' />
</font></td>
</tr>
</table>
<p><font face='Arial, Helvetica, sans-serif' size='-1'>
<input type='submit' name='Submit' value='Login' />
</font></p>
<p><font face='Arial, Helvetica, sans-serif' size='-1'><b><a href='../index.php'>back
to clients options</a></b></font> </p>
</form>
</td></tr>
</TABLE>
</div>
<?php
}
else
{
?>
<tr>
<td colspan=2>
<p><b><font face="Arial, Helvetica, sans-serif" size="-1"><br>
Windows:</font></b><font face="Arial, Helvetica, sans-serif" size="-1">
right click the link and choose "Save Target As"<br>
<b>Mac:</b> ctrl click and choose "Download Link to Disk"</font></p>
<p>
<?php
require '../../include.php';
$client_field = $_POST['client_txt'];
mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db($DBName);
$query = "SELECT * FROM itl_client_uploads WHERE client_id = '$client_field' ORDER BY upload_name DESC";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$upload_name = $row['upload_name'];
echo "<font face='Arial, Helvetica, sans-serif' size='-1'><a href='../Uploads/$upload_name'>$upload_name</a></font><br>";
}
?>
</p>
<p><font face='Arial, Helvetica, sans-serif' size='-1'><b><a href='../index.php'>back
to clients options</a></b></font></p></td>
</tr>
</TABLE>
</div>
<?php
}
?>
</body>
</html>
Thanks for your time
C