|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help with sessions
i'am trying to update a login script to work with php version 4.3 and have come up with following but i can't gt it to work. i am new to sessions so any help would be appreciated.
authmain.php <? session_start(); if ($_POST['userid'] && $_POST['password']) { // if the user has just tried to log in $db_conn = mysql_connect("localhost", "root", "choltas"); mysql_select_db("auth", $db_conn); $query = ("select * from auth where name='$_post[userid]' and pass='$_POST[password]'"); $result = mysql_query($query, $db_conn); if (mysql_num_rows($result) >0 ) { // if they are in the database register the user id $valid_user = $userid; $_SESSION['valid_user'] = $userid; } } ?> <html> <body> <h1>Home page</h1> <? if(isset($_SESSION['valid_user'])) //if (session_is_registered("valid_user")) { echo "You are logged in as: $valid_user <br>"; } else { if (isset($userid)) { echo "Could not log you in"; } else { echo "You are not logged in.<br>"; } member only.php if(isset($_SESSION['valid_user'])) //if (session_is_registered("valid_user")) { echo "<p>You are logged in as $valid_user.</p>"; PHP Code:
|
|
#2
|
|||
|
|||
|
try this,...
PHP Code:
__________________
-- Jason |
|
#3
|
|||
|
|||
|
thank you for your response, i had updated my code which looked similar to what you posted but all that happens is that the username and password disappear and nothing else happens
any ideas why |
|
#4
|
|||
|
|||
|
let me explain how I do it,...maybe it will make more sense.
PHP Code:
then you do your query... PHP Code:
if everything seems to be ok,..grab the array and set session vars. PHP Code:
I think you are missing the main function here ![]() PHP Code:
or PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > help with sessions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|