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 February 9th, 2005, 04:23 AM
Bagolapie Bagolapie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 Bagolapie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 48 sec
Reputation Power: 0
trouble with session variables

The problem is that I need to declare & use some session variables for logging in

this is the verify password file: just took out the ip's

<?php
session_start();

$connection = mysql_connect("???.???.??.???","root") or die ("Unable to connect to server.");

$db = mysql_select_db("users",$connection) or die ("Unable to find Reciept database.");

$sql = "SELECT password FROM users WHERE username = '$_POST[username]'";

$sql_result = mysql_query($sql, $connection) or die (mysql_error());

$row = mysql_fetch_array($sql_result);
$passcheck = $row["password"];



if ($_POST['password'] != $passcheck)
{
header("Location: http://???.???.??.???/php");
exit();
$_session['logg'] = "no";
}
else
{
header("Location: http://???.???.??.???/php/main.php");
exit();
$_session['logg'] = "yes";
}
?>

and then this is the main.php

<?php
session_start();

if($_session['logg'] = "no")
{
header("Location: http://155.238.93.171/php");
exit();
}
?>
<html>
<head>
<title>ICDL Prog</title>
...


but now the problem is that even if you logg in correctly main still sends you back to the logg in screen, even though $_session['logg'] should be = "yes";

Any help would be appreciated

Reply With Quote
  #2  
Old February 9th, 2005, 02:57 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 5
You need an extra equal sign in your log check. With only the single, you're actually setting $_SESSION['logg'] to 'no' instead of checking it.

Reply With Quote
  #3  
Old February 10th, 2005, 07:09 AM
kolkata kolkata is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 3 kolkata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 35 sec
Reputation Power: 0
Quote:
Originally Posted by Bagolapie
The problem is that I need to declare & use some session variables for logging in

this is the verify password file: just took out the ip's

<?php
session_start();

$connection = mysql_connect("???.???.??.???","root") or die ("Unable to connect to server.");

$db = mysql_select_db("users",$connection) or die ("Unable to find Reciept database.");

$sql = "SELECT password FROM users WHERE username = '$_POST[username]'";

$sql_result = mysql_query($sql, $connection) or die (mysql_error());

$row = mysql_fetch_array($sql_result);
$passcheck = $row["password"];



if ($_POST['password'] != $passcheck)
{
header("Location: http://???.???.??.???/php");
exit();
$_session['logg'] = "no";
}
else
{
header("Location: http://???.???.??.???/php/main.php");
exit();
$_session['logg'] = "yes";
}
?>

and then this is the main.php

<?php
session_start();

if($_session['logg'] = "no")
{
header("Location: http://155.238.93.171/php");
exit();
}
?>
<html>
<head>
<title>ICDL Prog</title>
...


but now the problem is that even if you logg in correctly main still sends you back to the logg in screen, even though $_session['logg'] should be = "yes";

Any help would be appreciated


I just telling u that u have some miscoding in u'r script.
$connection = mysql_connect("???.???.??.???","root","password")
$sql = "SELECT password FROM users WHERE username = '$_POST[username]'";
It should $_POST['username']
one more thing as per my knowledge
u use relative path in header function.just mention the name of file if both are in same folder.
tried it out

Reply With Quote
  #4  
Old February 24th, 2005, 08:49 PM
drydell drydell is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 drydell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 9 sec
Reputation Power: 0
another thing you need to do is set your session variables and callsession_write_close() before calling header()

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > trouble with session variables


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 1 hosted by Hostway
Stay green...Green IT