PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 7th, 2005, 12:08 PM
indy77 indy77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 5 indy77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 0
Help With Login Scripts

I'm very new with PHP, i just design my login page. But seems like i can't login using my own email and password. Can any one tell me where i'm doing wrong. Can any one help with this.Thanks . The scripts i'm using is as follows:


<?php
//
// db.private
// This file holds the $username and $password variables etc
// Read how to protect your password in db.private/db.inc
//
$hostname = "localhost";
$databaseName = "xxxxxxx"; // Change these values to your own database name
$username = "xxxxx"; // user id and password.
$password = "xxxxxx";
?>


<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="") $FF_LoginAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
if (isset($HTTP_POST_VARS['email'])) {
$FF_valUsername=$HTTP_POST_VARS['email'];
$FF_valPassword=$HTTP_POST_VARS['password'];
$FF_fldUserAuthorization="";
$FF_redirectLoginSuccess="bookings/yourbookings.php";
$FF_redirectLoginFailed="failedlogin.php";
$FF_rsUser_Source="SELECT Email, password ";
if ($FF_fldUserAuthorization != "") $FF_rsUser_Source .= "," . $FF_fldUserAuthorization;
$FF_rsUser_Source .= " FROM customer WHERE Email='" . $FF_valUsername . "' AND password='" . $FF_valPassword . "'";
$connection = mysql_connect($hostname,$username,$password);
mysql_select_db($databaseName, $connection);
$FF_rsUser=mysql_query($FF_rsUser_Source, $connection) or die(mysql_error());
$row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
if(mysql_num_rows($FF_rsUser) > 0) {
// username and password match - this is a valid user
$MM_Username=$FF_valUsername;
session_register("MM_Username");
if ($FF_fldUserAuthorization != "") {
$MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
} else {
$MM_UserAuthorization="";
}
session_register("MM_UserAuthorization");
if (isset($accessdenied) && false) {
$FF_redirectLoginSuccess = $accessdenied;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");
$FF_login_failed = false;

$resouser = $_POST['email'];
$resouser = stripslashes($resouser);
session_register('resouser');
$_SESSION['resouser'] = $resouser;

header ("Location: $FF_redirectLoginSuccess");
exit;
}
mysql_free_result($FF_rsUser);
session_register("FF_login_failed");

$FF_login_failed = true;
header ("Location: $FF_redirectLoginFailed");
exit;
}
?>

Reply With Quote
  #2  
Old March 7th, 2005, 02:09 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
In the future, wrap your PHP code in [php][/php] tags

Are you getting an error?
What's happening?

Reply With Quote
  #3  
Old March 7th, 2005, 04:01 PM
indy77 indy77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 5 indy77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 0
Thanks For Reply.
The error i'm getting is when i put my email and password. It's generate the same page but emty Email and passowrd field.
So seems like its checking the database but not displaying it. But if i put wrong email and passowrd just came back with
your email and passowrd not registered.
Thanks






Quote:
Originally Posted by MadCowDzz
In the future, wrap your PHP code in tags

Are you getting an error?
What's happening?

Reply With Quote
  #4  
Old March 8th, 2005, 08:57 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I trust you've put the X's in the DB variables for masking reasons right?
I ask because it appears your code was generated by Macromedia or something similar [often people forget to update those variables]

What's at bookings/yourbookings.php?
Is that your form, or is that the page you expect to see after logging in correctly?

It's possible that yourbookings.php isn't receiving the session variables properly so it's throwing you back to the login form.

Reply With Quote
  #5  
Old March 9th, 2005, 01:28 PM
indy77 indy77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 5 indy77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 0
Thats's right the x is just for masking reason. And after login page sucessful i like to see yourbooking.php.
The coding for yourbooking.php as follows:



<?php
//
// db.private
// This file holds the $username and $password variables etc
// Read how to protect your password in db.private/db.inc
//
$hostname = "studb.cms.gre.ac.uk";
$databaseName = "xxxxxx"; // Change these values to your own database name
$username = "xxxxxx"; // user id and password.
$password = "xxxxxxx";
?>

<?php
// *** Logout the current user.
$FF_Logout = $HTTP_SERVER_VARS['PHP_SELF'] . "?FF_Logoutnow=1";
if (isset($HTTP_GET_VARS['FF_Logoutnow']) && $HTTP_GET_VARS['FF_Logoutnow']=="1") {
session_start();
session_unregister("MM_Username");
session_unregister("MM_UserAuthorization");
$FF_logoutRedirectPage = "../logout.php";
// redirect with URL parameters (remove the "FF_Logoutnow" query param).
if ($FF_logoutRedirectPage == "") $FF_logoutRedirectPage = $HTTP_SERVER_VARS['PHP_SELF'];
if (!strpos($FF_logoutRedirectPage, "?") && $HTTP_SERVER_VARS['QUERY_STRING'] != "") {
$FF_newQS = "?";
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
if($key != "FF_Logoutnow"){
if (strlen($FF_newQS) > 1) $FF_newQS .= "&";
$FF_newQS .= $key . "=" . urlencode($val);
}
}
if (strlen($FF_newQS) > 1) $FF_logoutRedirectPage .= $FF_newQS;
}
header("Location: $FF_logoutRedirectPage");
exit;
}

// *** Restrict Access To Page: Grant or deny access to this page
$FF_authorizedUsers=" ";
$FF_authFailedURL="../login.php";
$FF_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS["MM_Username"])) {
if (true || !(isset($HTTP_SESSION_VARS["MM_UserAuthorization"])) || $HTTP_SESSION_VARS["MM_UserAuthorization"]=="" || strpos($FF_authorizedUsers, $HTTP_SESSION_VARS["MM_UserAuthorization"])) {
$FF_grantAccess = 1;
}
}
if (!$FF_grantAccess) {
$FF_qsChar = "?";
if (strpos($FF_authFailedURL, "?")) $FF_qsChar = "&";
$FF_referrer = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0) $FF_referrer .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
$FF_authFailedURL = $FF_authFailedURL . $FF_qsChar . "accessdenied=" . urlencode($FF_referrer);
header("Location: $FF_authFailedURL");
exit;
}

$colname_Bookings = "1";
if (isset($HTTP_SESSION_VARS['resouser'])) {
$colname_Bookings = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['resouser'] : addslashes($HTTP_SESSION_VARS['resouser']);
}
$connection = mysql_connect($hostname,$username,$password);
mysql_select_db($databaseName, $connection);
$query_Bookings = sprintf("SELECT ConfirmID, ReservationDate, ExpectedCheckinDate, RoomRate FROM reservation WHERE CustomerEmail = '%s'", $colname_Bookings);
$Bookings = mysql_query($query_Bookings, $connection) or die(mysql_error());
$row_Bookings = mysql_fetch_assoc($Bookings);
$totalRows_Bookings = mysql_num_rows($Bookings);
?>

Reply With Quote
  #6  
Old March 9th, 2005, 01:47 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
When you post code, try wrapping it in [php][/php] tags; this will keep your indentation and colorize your code making it easier for us to read.

the first peice of code you posted says:
$FF_redirectLoginSuccess="bookings/yourbookings.php";

you were just calling it "yourbooking.php"... might there be a spelling mistake in your code?

Reply With Quote
  #7  
Old March 9th, 2005, 05:58 PM
indy77 indy77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 5 indy77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 0
Sorry the second scripts taken from:

bookings/yourbookings.php";


I checked this no spelling mistake

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help With Login Scripts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT