logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-21-2008, 01:52 AM   #1
Bike Racer
 
Join Date: Apr 2008
Posts: 18
Default Help with login video tutorial

I really enjoy your tutorials!!! I'm having problems though with the login tutorial. I set up the login page and everything seems to be working fine.
PHP Code:
<?php 
require_once("Connections/testserver.php");

session_start();

//Catch Field Data
$userid     =         $_POST['userid'];
$password     =        $_POST['password'];
$submitted     =         $_POST['submitted'];

if (
$userid && $password) {
/////////////////////////////////////////////
$query         =     sprintf("SELECT * FROM night where user_name='$userid' and user_password = '$password'");
$result     =       mysql_query($query);
$rowAccount =     mysql_fetch_array($result);
/////////////////////////////////////////////
}
if (
$rowAccount) {

$_SESSION['id'] = $rowAccount['user_id'];

header("location:success.php");
exit;

 
}elseif(
$submitted){

echo 
"You don't exist";
}

?>
This will kick me to the "success.php" page. When I add the php to the success page I get kicked out when logging in.

PHP Code:
<?php 
require_once("Connections/testserver.php");

session_start();

if (!isset(
$_SESSION['id'])){

header("location: mylogin.php");
exit;

}

$id $_SESSION['id'];

////////////////////////////
$query        =sprintf("SELECT * FROM night where user_id='$id'");
$result        =mysql_query($query);
$rowAccount    =mysql_fetch_array($result);
/////////////////////////////



?>
It seems too me that SESSION id it not being set on the login page. If I take the ! out of isset I will not get kicked out.

Am I missing something?

Thanks
Bike Racer is offline   Reply With Quote
Old 04-21-2008, 06:24 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

comment out the ...

PHP Code:
//header("location:success.php"); 
then echo the SESSION contents to see if its set with the user_id value when you try to log in
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-21-2008, 12:44 PM   #3
Bike Racer
 
Join Date: Apr 2008
Posts: 18
Default

Thanks David,

///header("location:success.php");
echo $rowAccount['user_id'];
///exit;

returned - 1
Bike Racer is offline   Reply With Quote
Old 04-21-2008, 12:46 PM   #4
Bike Racer
 
Join Date: Apr 2008
Posts: 18
Default

///header("location:success.php");
echo $_SESSION['id'];
///exit;

Also returned 1
Bike Racer is offline   Reply With Quote
Old 04-21-2008, 01:03 PM   #5
Bike Racer
 
Join Date: Apr 2008
Posts: 18
Default

on success.php

This returned nothing

session_start();
echo $_SESSION['id']
Bike Racer is offline   Reply With Quote
Old 04-22-2008, 06:05 AM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

did you terminate the session with a semi colon
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-22-2008, 10:51 AM   #7
Bike Racer
 
Join Date: Apr 2008
Posts: 18
Default

I did. My web hosting service is also looking into the problem. The sever behavior within DW created the same problem. - a correct username/password directs me back to the login page. Thanks for your help. If I sent you the link would you be willing to take a look at it?
Bike Racer is offline   Reply With Quote
Old 04-23-2008, 06:12 AM   #8
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

if you sent a link there wont be any php to troubleshoot
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com