The scenario...
(a page called login.php)A user logs in via a form submitting user/pass which is check against database - which works.....
(a page called update.php)If the user is a certain type of member, a form is then loaded to fill in info - which works.....
(a page called validate when submit is clicked)After the users fill in the form and clicks submit....i cannot tell the database which row to put the data into as the $variables created after the user logs in are wiped and cannot be accessed when the user clicks submit on the second form....I can only access all the variables created inside the form, and not thos PHP variables outside the form....
Snippets of code:
Page 1 - Login form
<FORM METHOD=post ACTION="update.php" name="memberLogin">
<p>
<table width="500" border="0" cellspacing="1" cellpadding="5" align="center">
<tr>
<td align="right" valign="top" width="225">Username:</td>
<td align="left" valign="middle"><input type="text" name="userID" maxlength="15" size="15">
</td>
</tr>
Page 2 - update form
// Connecting, selecting database
$link = mysql_connect($dbhost, $dbname, $dbpasswd)
or die("Could not connect");
mysql_select_db($dbname)
or die("Could not select database<BR><BR>");
$userPass = md5($userPass);
$sql = mysql_query("SELECT * FROM atest_users WHERE user_password='$userPass' and username='$userID'")
or die("Invalid query");
$num = mysql_num_rows($sql);
if ($num != "0")
{
$isBorn = mysql_result ($sql, 0, "user_born");
$memberID = mysql_result ($sql, 0, "user_id");
}
If Login Is Okay Do What You Want TO DO to Them
if ($submit == "Update")
{
$memberFavGun = $radioGun;
$memberFavModel = $radioModel;
$memberFavMap = $radioMap;
$memberFavQuote = $memberQuote;
$memberProcessor = $memberPcProcessor;
$memberRam = $memberPcRam;
$memberVideo = $memberPcVideo;
$memberSound = $memberPcSound;
$memberMonitor = $memberPcMonitor;
$memberInternet = $radioInternet;
echo "<font color=\"#0000FF\">$member here</font><BR>";
echo "<font color=\"#0000FF\">$memberID here 2</font><BR><BR><BR>";
echo "<font color=\"#0000FF\">$memberFavGun</font><BR>";
echo "<font color=\"#0000FF\">$memberFavModel</font><BR>";
echo "<font color=\"#0000FF\">$memberFavMap</font><BR>";
echo "<font color=\"#0000FF\">$memberFavQuote</font><BR>";
echo "<font color=\"#0000FF\">$memberProcessor</font><BR>";
echo "<font color=\"#0000FF\">$memberRam</font><BR>";
echo "<font color=\"#0000FF\">$memberVideo</font><BR>";
echo "<font color=\"#0000FF\">$memberSound</font><BR>";
echo "<font color=\"#0000FF\">$memberMonitor</font><BR>";
echo "<font color=\"#0000FF\">$memberInternet</font><BR>";
}
else
{
if (($num == "1") && ($isBorn == 1))
{
echo "<font color=\"#000099\">Member details:</font><BR>";
echo "<font color=\"#000099\">Member Name: $userID</font><BR>";
echo "<font color=\"#000099\">Member ID: $memberID</font><BR>";
echo "<font color=\"#000099\">Member IsBORN (1 is YES): $isBorn</font><BR>";
?>
<body>
<FORM METHOD=post ACTION="update.php" name="memberInfo">
<p>
<table width="750" border="0" cellspacing="1" cellpadding="5" align="center">
<tr>
<td align="left" valign="bottom" width="250"><h2> Favourite Gun</h2></td>
<td align="left" valign="bottom" width="250"><h2> Favourite Model</h2></td>
<td align="left" valign="bottom" width="250"><h2> Favourite Map</h2></td>
=====================================
Note: some lines are un-needed as they are for debugging...
You can see what i mean at:
http://reborn.ausgamers.com/members/login.php
Username: Kr@mee Pass: test
What I need to do, is pass the PHP variable $memberID (which is 2, youll see when you login), however when you click update, it only passes through the form variables...youll note 2 debug messages "here" and "here 2" before that would be the $memberID variable so I know which row to put the data in. (eg. it should say either "2 here" or "2 here 2"