First time here. Let's hope this works!
I'm new to PHP and trying to create a site where users have their own page with content they can edit. I got the login system to halfway work. It recognizes usernames and passwords correctly, but it does not seem to be storing the $_SESSION variable. At first I thought it was because I was trying to make the username (itself a variable) the $_SESSION variable, but even when I set it to something absolute, my code to check to see if the user is logged in redirects them to the "you are not logged in" page. Here is my verification php code:
<?php
$host="xxxx.ipagemysql.com";
$username="xxxxx";
$password="xxxxxx";
$db_name="farmers";
$tbl_name="users";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$farmeruser=$_POST['farmeruser'];
$farmerpw=$_POST['farmerpw'];
$sql="SELECT * FROM ".$tbl_name." WHERE farmeruser='".$farmeruser."' and farmerpw='".$farmerpw."';";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_start();
$_SESSION['member'] = "affirmative";
header("location:succesful_login.php");
}
else {
echo "Wrong Username or Password";
}
?>
And here is my page that is never recognizing that the user is logged in:
<?php
session_start();
if($_SESSION['member'] == "affirmative")
{
echo
"Welcome!";
}
else {
header('Location: http://www.leukosweb.com/user_not_recognized.php');
}
?>
Any Ideas why this is not working?
PS. I would like to change "affirmative" to the user's login name. If you want to help me set the $_SESSION 'member' variable using a variable in the login varification page, that would also be awesome!