itcep200870
New Member
- Messages
- 3
- Reaction score
- 0
- Points
- 0
my php code for login
code in main page .php
results output
session variable was not set
help me plzzzzzzzzzzzz
PHP:
<?php
$db_host = 'localhost'; // don't forget to change
$db_user = 'cepit08_root';
$db_pwd = 'root1';
$database = 'cepit08_cepit';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
if($res=mysql_fetch_array(mysql_query("SELECT * FROM login WHERE username='$_POST[username]' AND password = '$_POST[password]'"))){
if(($res['username']==$_POST[username])&&($res['password']==$_POST[password])){
session_start();
$_session['username']=$_POST[username];
header("Location:http://www.cepit08.x10.mx/mainpage.php");
die();
}
}
else {
header("Location:http://www.cepit08.x10.mx/index.php?msg=Invalid username or password");
}
?>
PHP:
<?php
session_start();
if (isset($_SESSION['username']))
{
echo $_SESSION['username'];
}
else
{
echo "session variable was not set";
}
?>
session variable was not set
help me plzzzzzzzzzzzz
Last edited: