944,175 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1163
  • PHP RSS
Apr 21st, 2006
0

Do You Know Sessions! HELP PLEASE!

Expand Post »
DO YOU KNOW WHY THIS IS NOT WORKING ALL THE TIME ONLY SOMETIMES!


okay on my Login Page I Have At The Very Top

<?php
session_start();
?>

FOLLOWED BY THE LOGIN FORM THAT GOES TO welcome.php PAGE

<table class="form">
<form name="login_form" method="POST" action="welcome.php">
<tr>
<td>
<p class="b">Email Address<br>
<input name="email_address" type="text" "$email_address" value="">
</p>


<p class="c">Password<br>
<input name="password" type="password" "$password" value="">
</p>

<p class="d">
<input type="HIDDEN" name="$session_name" value="$session_id">
</p>

<p class="e"><input type="submit" name="Submit" value="Activate Here!">
</p>
</form>
</td>
</tr>
</table>


AS SHOWN THIS GOES TO THE welcome.php PAGE - NOW ON THE welcome.php PAGE AT THE VERY TOP I AGAIN HAVE :

<?php
session_start();
?>


FOLLOWED BY THIS CODE SECURITY AND THE USER IS GREETED BY NAME: Thanks To DGStudios! Helping me with that code.


<?
include 'db.php';

// get the variables from home page
$password = $_REQUEST['password'];
$email_address = $_REQUEST['email_address'];


$sql_check = mysql_query("SELECT username FROM myd WHERE password='$password' AND
email_address='$email_address'");
$username = mysql_fetch_array($sql_check, MYSQL_ASSOC); //MYSQL_ASSOC;
$sql_check_num = mysql_num_rows($sql_check);
if($sql_check_num == 0){

echo ("You Must Login Or Signup!");
} else {
echo 'Welcome '.$username['username'];
}

// Define post fields into simple variables
$email_address = $_REQUEST['email_address'];
$password = $_REQUEST['password'];

/* Let's strip some slashes in case the user entered
any escaped characters. */

$email_address = stripslashes($email_address);
$password = stripslashes($password);

/* Do some error checking on the form posted fields */

if((!$email_address) || (!$password)){
echo '<STRONG><br><br>Enter required fields as indicated below
<br>If you are a member!</STRONG><a href="login_form.php"><u> Login Here</u></a>
<br><STRONG>To become a member!</STRONG><a href="join_form.php"><u> Join Here</u>
</a><BR><br />';
if(!$email_address){
echo "<font color='#000000'>Email address is a required field.</font><br />";
}
if(!$password){
echo "<font color='#000000'>Password is a required field.</font><br />";
}
exit(); // if the error checking has failed, we'll exit the script!
}

?>


THE USER IS IN AND IS GREETED BY NAME... WHAT I THOUGHT I COULD DO WAS REPLACE $_REQUEST
WITH $_SESSION SO MY USER COULD GO TO VARIOUS LINKS AVAILABLE FROM THE welcome.php PAGE
AND STAY IN THEIR SESSION... SHOULDN"T THAT WORK!

ON THE LINK PAGES I ADDED THE SAME CODE THAT IS ON THE welcome.php PAGE AND Of COURSE I HAVE THE session_start(): AT THE TOP OF EVERY LINKED PAGE -

BUT IT'S NOT CONSISTANTLY WORKING... LIKE IT WORKS SOMETIMES IT'S CRAZY - THAN OTHER TIMES IT SAYS ON EVERYPAGE TO LOGIN... OR SIGNUP!

IS THIS ERROR FROM MY SERVER? OR IS MY CODE WRONG?

I HAVE REGISTER GLOBALS OFF I AM NOT USING COOKIES AND I DO NOT WANT TO USE THE GET METHOD

Thank-You Kindly I'm going in circles...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
puddin is offline Offline
52 posts
since Mar 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need Freelancing Partner
Next Thread in PHP Forum Timeline: php adodb library connect remote mysql





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC