PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jkelly
Forum Newbie
Posts: 6 Joined: Tue May 31, 2005 10:12 am
Post
by jkelly » Tue May 31, 2005 10:31 am
Hello,
I'm a complete newbie at PHP and am having an awful lot of trouble trying to pass username and password information from one page to the other..
The problem is, on one page I have textfields where the user enters their username and password and then clicks on submit. This brings them to another page that should display their information.
The probalem is, I cant seem to be able to bring the information they entered in the first page across to the second page...
I am trying to use _POST to do this but to no avail...
Any help would be very appreciated!!!
Cheers,
John
Revan
Forum Commoner
Posts: 83 Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:
Post
by Revan » Tue May 31, 2005 10:44 am
jkelly
Forum Newbie
Posts: 6 Joined: Tue May 31, 2005 10:12 am
Post
by jkelly » Tue May 31, 2005 10:55 am
Hey,
Cheers for the reply. All I get when I do that is
...which I figure means the POST array isnt being filled in the first page..
The code on the first page is
Code: Select all
$loginUsername = $_POSTї'username'];
which is referring to the username textfield... any idea on what I'm doing wrong?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue May 31, 2005 10:57 am
show us the code for your form
jkelly
Forum Newbie
Posts: 6 Joined: Tue May 31, 2005 10:12 am
Post
by jkelly » Tue May 31, 2005 11:16 am
Here's the code that I think is relevent on the first page
Code: Select all
<?php require_once('Connections/final.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();
$loginFormAction = $_SERVERї'PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALSї'PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}
if (isset($_POSTї'username']))
{
$loginUsername=$_POSTї'username'];
$password=$_POSTї'password'];
$fldUserAuthorization = "e;"e;;
$redirectLoginSuccess = "e;checkout.php"e;;
$redirectLoginFailed = "e;ERRregForm.php"e;;
$redirecttoReferrer = false;
mysql_select_db($database_final, $final);
$LoginRS__query=sprintf("e;SELECT username, Password FROM customer WHERE username='"e; . $loginUsername . "e;' AND Password='"e; . $password . "e;'"e;);
$LoginRS = mysql_query($LoginRS__query, $final) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "e;"e;;
//declare two session variables and assign them
$GLOBALSї'Username'] = $loginUsername;
$GLOBALSї'UserGroup'] = $loginStrGroup;
//register the session variables
session_register("e;Username"e;);
session_register("e;UserGroup"e;);
if (isset($_SESSIONї'PrevUrl']) && false) {
$redirectLoginSuccess = $_SESSIONї'PrevUrl'];
}
header("e;Location: "e; . $redirectLoginSuccess );
}
else {
header("e;Location: "e;. $redirectLoginFailed );
}
}
That is the top section of my php file and then the related textfields are created below with this code
Code: Select all
<form ACTION="e;<?php echo $loginFormAction; ?>"e; name="e;frmCart"e; method="e;POST"e;>
...etc
<input name="e;username"e; type="e;text"e; id="e;username"e;>
</strong></font></p>
<p align="e;center"e;><font size="e;+1"e;><strong>Password:
<input name="e;password"e; type="e;password"e; id="e;password"e;>
</strong></font></p>
<p align="e;center"e;><strong>
<input type="e;submit"e; name="e;Submit"e; value="e;Submit"e;>
</strong></p>
</form>
Thanks for all the help too!!