PHP login Script help with sessions
Posted: Tue Mar 31, 2009 8:12 pm
I have a login script in which it works fine. on my homepage i want it to display the first name of the user. I have it where i can show the username but nothing else.
I have tried different sessions and mysql functions nothing works. Any Suggestions.
My Login page is
My Home page is
I have tried different sessions and mysql functions nothing works. Any Suggestions.
My Login page is
Code: Select all
include ("functions.php");
session_start();
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' or email='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
$_SESSION['username'] = $myusername;
session_register("myusername");
session_register("mypassword");
header("location:?x=home");
}
else {
echo "Wrong Username or Password";
login();
}
ob_end_flush();Code: Select all
<?php
session_start();
require_once ACCOUNT_DIR . 'functions.php';
session_start();
if(!session_is_registered(myusername)){
login();
}
if(session_is_registered(myusername)){
echo "<a href=\"?x=logout\">Logout</a>\n";
echo $_SESSION['username'];
?>