Hi there,
A warning up front: I'm trying to modify code written by someone else and I don't know PHP. Ha! Thank you in advance for any help you can offer.
I am editing a website where users login to download media files - audio files are kept in the audio directory, video files in the video directory. The site owner initially had it set up so that there was a form for each: users would enter the appropriate user/pass combo in the audio form to be taken to a php page that listed the contents of the audio directory. If they wanted the video directory, they had to login using the video form. (There is one user/pass combo for each.)
They were told that separate forms were unnecessary and redundant, and now they realize that's true. My job is to modify the code so there's only one form, and the user/pass entered determines which directory contents are displayed.
Here's what the code looks like now:
$page ="";
$login="";
$password="";
$dir="";
if (isset($_GET['page']))
{
$page = $_GET['page'];
}
if (isset($_POST['login']))
{
$login = $_POST['login'];
$password = $_POST['password'];
$dir = $_POST['dir'];
}
include("header.inc");
If ($page =='pickup' AND $login == "video" AND $password == "bob" AND $dir =="video" )
{include "video.php";}
Elseif ($page =='pickup' AND $login == "audio" AND $password == "frank" AND $dir =="audio" )
{include "audio.php";}
Then the pickup page, where the user logs in, looks like this:
<FORM ACTION="form.php?page=pickup" METHOD="post">
<TABLE BORDER=0>
<TR>
<TD ALIGN="right">Login:</TD>
<TD><INPUT TYPE="text" NAME="login"></INPUT></TD>
</TR>
<TR>
<TD ALIGN="right">Password:</TD>
<TD><INPUT TYPE="password" NAME="password"></INPUT>
<input type="hidden" name="page" value="pickup" />
<input type="hidden" name="dir" value="audio" />
</TD>
</TR>
<TR>
<TD ALIGN="right"></TD>
<TD><INPUT TYPE="submit" VALUE="Login"></INPUT>
<INPUT TYPE="reset" VALUE="Reset"></INPUT>
</TD>
</TR>
</TABLE>
</FORM>
Then the same form again, except the directory value is "video".
How do I "combine" these into one form, where the directory value is determined based upon the user/pass entered?
I hope that makes sense - thank you!!
MOD EDIT: bbcode tags added to make code easier to read and analyze; please use these tags in the future!