Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 8th, 2005, 11:20 AM
Authorized User
Join Date: Jan 2005
Location: ipaja, lagos, Nigeria.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to p2ptolu Send a message via Yahoo to p2ptolu
Default please php is not working perfectly well

i used this code but it does not work am working on win xp pro, apache 1.33, php 4.3 mysql 3.23 it does not go beyond the login page


<form action="loginaction.php" method="Post">
Email Address:<br />
<input type="Text" name="psEmail" />
<br />
Password:<br />
<input type="password" name="psPassword" />
<br />
<input type="submit" value="Login" />
<input type="hidden" name="psRefer" value="<? echo($refer) ?>"


// Check if the information has been filled in
if($psEmail == '' || $psPassword == '') {
// No login information
header('Location: Login.php?refer='.urlencode($psRefer));
} else {
// Authenticate user
$hDB = mysql_connect('localhost', 'root', 'leathaface');
mysql_select_db('tblusers', $hDB);
$sQuery = "
From tblUsers
Where sEmail = '$psEmail'
And sPassword = password('$psPassword')";
$hResult = mysql_query($sQuery, $hDB);
if(mysql_affected_rows($hDB)) {
$aResult = mysql_fetch_row($hResult);
// Update the user record
$sQuery = "
Update tblUsers
Set sGUID = '$aResult[1]'
Where iUser = $aResult[0]";
mysql_query($sQuery, $hDB);
// Set the cookie and redirect
setcookie("session_id", $aResult[1]);
if(!$psRefer) $psRefer = 'index.php';
header('Location: '.$psRefer);
} else {
// Not authenticated
header('Location: Login.php?refer='.urlencode($psRefer));


// Check for a cookie, if none got to login page
if(!isset($HTTP_COOKIE_VARS['session_id'])) {
header('Location: Login.php?refer='.urlencode($PHP_SELF.'?'.$HTTP_SE RVER_VARS['QUERY_STRING']));
// Try to find a match in the database
$sGUID = $HTTP_COOKIE_VARS['session_id'];
$hDB = mysql_connect('localhost', 'root', 'leathaface');
mysql_select_db('tblusers', $hDB);
$sQuery = "
Select iUser
From tblUsers
Where sGUID = '$sGUID'";
$hResult = mysql_query($sQuery, $hDB);
if(!mysql_affected_rows($hDB)) {
// No match for guid
header('Location: Login.php?refer='.urlencode($PHP_SELF.'?'.$HTTP_SE RVER_VARS['QUERY_STRING']));

Old March 27th, 2005, 09:56 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts

You have register_globals disabled. You should reference input data via its corresponding superglobal.

psPassword is not access as $psPassword it is $_POST['psPassword']. (BTW, the longer $HTTP_*_VARS names are deprecated)


Want to know more about registrer_globals?


Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design

Similar Threads
Thread Thread Starter Forum Replies Last Post
Will this query run perfectly??? ... rupen Access 2 August 1st, 2006 06:11 AM
working with php pritz Beginning PHP 2 September 11th, 2005 02:28 PM
php 5 not working with mysql fromheavenz PHP Databases 0 August 30th, 2005 12:31 PM
Working with ImageCreate in PHP? jwang Pro PHP 4 February 24th, 2004 01:50 PM
ASP not working after installing PHP taliesin Classic ASP Basics 0 June 27th, 2003 12:39 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.