By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,208 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,208 IT Pros & Developers. It's quick & easy.

Php/MySQL Login - Can anyone give me suggestion as to why thiscode does not work ?

P: n/a
RT
I have followed the step by step instructions in the login manual

Created login page
Use LSC01

This works - login and get redirected to the proper page
My problem is the cookie variables donıt show up (created setsessions.php
page and readsessions.php to test - works)

On the page, Iıve applied LSC03 * Access by Cookie * this seems to work
since it allows my to enter the page I want

I then applied the LSC05 * User Details -
The correct rsUserDetails is set up

I then include Dynamic Text to the page that is suppose to show the
registered users information but it doesnıt

Have torn page apart 50 million times I know itıs one line or something
extremely simple but I canıt figure it out.

HELP HELP

Thanks

Code for login page

<?php require_once('../../Connections/reg.php'); ?>
<?php
// Buzz inet PHPLSC01 - Login & Set Cookie
$myUsername_rsLogin = "0";
if (isset($HTTP_POST_VARS['email'])) {
$myUsername_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['email']
: addslashes($HTTP_POST_VARS['email']);
}
$myPassword_rsLogin = "0";
if (isset($HTTP_POST_VARS['password'])) {
$myPassword_rsLogin = (get_magic_quotes_gpc()) ?
$HTTP_POST_VARS['password'] : addslashes($HTTP_POST_VARS['password']);
}
mysql_select_db($database_reg, $reg);
// Verify Login is correct
$query_rsLogin = sprintf("SELECT email, password FROM parent WHERE email=
'%s' AND password = '%s'", $myUsername_rsLogin,$myPassword_rsLogin);
$rsLogin = mysql_query($query_rsLogin, $reg) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);

// Buzz inet PHPLSC01 - Login & Set Cookie
// Check Login, Set Cookie and Redirect else show Error Message
if($HTTP_POST_VARS['action']=="login"){
if($totalRows_rsLogin==0){
$errorMessage = "Please Try agin or Create a New Parent Account";
mysql_free_result($rsLogin);
} else {
mysql_free_result($rsLogin);
setcookie("PWlogintest",$HTTP_POST_VARS['email'],time() +
2592000,"/");
// Expire Date: 30
// Expire Time: 12:00:00
header("Location: /pages/registrationtest/registration.php");
}
}
?>

Code for page I want info on:

<?php require_once('../../Connections/reg.php'); ?>
<?php
// Buzz inet PHPLSC03 - Check User Cookie is set
if(!isset($HTTP_COOKIE_VARS['PWlogintest'])){
header("Location: /pages/registrationtest/welcomereg.php");
}

// Buzz inet PHPLSC05 - User Details
?>
<?php
$varSearch_rsUserDetails = "1";
if (isset($HTTP_COOKIE_VARS['PWlogintest'])) {
$varSearch_rsUserDetails = (get_magic_quotes_gpc()) ?
$HTTP_COOKIE_VARS['PWlogintest'] :
addslashes($HTTP_COOKIE_VARS['PWlogintest']);
}
mysql_select_db($database_reg, $reg);
$query_rsUserDetails = sprintf("SELECT * FROM parent WHERE email = '%s'",
$varSearch_rsUserDetails);
$rsUserDetails = mysql_query($query_rsUserDetails, $reg) or
die(mysql_error());
$row_rsUserDetails = mysql_fetch_assoc($rsUserDetails);
$totalRows_rsUserDetails = mysql_num_rows($rsUserDetails);
?>
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Php/MySQL Login - Can anyone give me suggestion as to why this code does not work ?Your code is outputing something before calling setcookie:

<?php require_once('../../Connections/reg.php'); ?>[CR][LR] <---
<?php

Combine the two code blocks.
Uzytkownik "RT" <ro******@comcast.net> napisal w wiadomosci news:BC52AAFE.BB7A%ro******@comcast.net...
I have followed the step by step instructions in the login manual

Created login page
Use LSC01

This works - login and get redirected to the proper page
My problem is the cookie variables don't show up (created setsessions.php page and readsessions.php to test - works)

On the page, I've applied LSC03 - Access by Cookie - this seems to work since it allows my to enter the page I want

I then applied the LSC05 - User Details -
The correct rsUserDetails is set up

I then include Dynamic Text to the page that is suppose to show the registered users information but it doesn't

Have torn page apart 50 million times I know it's one line or something extremely simple but I can't figure it out.

HELP HELP

Thanks

Code for login page

<?php require_once('../../Connections/reg.php'); ?>
<?php
// Buzz inet PHPLSC01 - Login & Set Cookie
$myUsername_rsLogin = "0";
if (isset($HTTP_POST_VARS['email'])) {
$myUsername_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['email'] : addslashes($HTTP_POST_VARS['email']);
}
$myPassword_rsLogin = "0";
if (isset($HTTP_POST_VARS['password'])) {
$myPassword_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['password'] : addslashes($HTTP_POST_VARS['password']);
}
mysql_select_db($database_reg, $reg);
// Verify Login is correct
$query_rsLogin = sprintf("SELECT email, password FROM parent WHERE email= '%s' AND password = '%s'", $myUsername_rsLogin,$myPassword_rsLogin);
$rsLogin = mysql_query($query_rsLogin, $reg) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);

// Buzz inet PHPLSC01 - Login & Set Cookie
// Check Login, Set Cookie and Redirect else show Error Message
if($HTTP_POST_VARS['action']=="login"){
if($totalRows_rsLogin==0){
$errorMessage = "Please Try agin or Create a New Parent Account";
mysql_free_result($rsLogin);
} else {
mysql_free_result($rsLogin);
setcookie("PWlogintest",$HTTP_POST_VARS['email'],time() + 2592000,"/");
// Expire Date: 30
// Expire Time: 12:00:00
header("Location: /pages/registrationtest/registration.php");
}
}
?>

Code for page I want info on:

<?php require_once('../../Connections/reg.php'); ?>
<?php
// Buzz inet PHPLSC03 - Check User Cookie is set
if(!isset($HTTP_COOKIE_VARS['PWlogintest'])){
header("Location: /pages/registrationtest/welcomereg.php");
}

// Buzz inet PHPLSC05 - User Details
?>
<?php
$varSearch_rsUserDetails = "1";
if (isset($HTTP_COOKIE_VARS['PWlogintest'])) {
$varSearch_rsUserDetails = (get_magic_quotes_gpc()) ? $HTTP_COOKIE_VARS['PWlogintest'] : addslashes($HTTP_COOKIE_VARS['PWlogintest']);
}
mysql_select_db($database_reg, $reg);
$query_rsUserDetails = sprintf("SELECT * FROM parent WHERE email = '%s'", $varSearch_rsUserDetails);
$rsUserDetails = mysql_query($query_rsUserDetails, $reg) or die(mysql_error());
$row_rsUserDetails = mysql_fetch_assoc($rsUserDetails);
$totalRows_rsUserDetails = mysql_num_rows($rsUserDetails);
?>

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.