i get a notice
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\teller\fungsi.php on line 2
Notice: Use of undefined constant status - assumed 'status' in C:\xampp\htdocs\teller\fungsi.php on line 17
Notice: Use of undefined constant status - assumed 'status' in C:\xampp\htdocs\teller\fungsi.php on line 20
in my code. I try this function in the old my sql version was success. but in my sql versi 5.5.16 it doesn't work. this is my source code :
<?php
session_start();
function ver_user($username,$password)
{
mysql_connect('localhost', 'root', '');
mysql_select_db('teller');
if (!empty($username))
{
$query="SELECT * FROM `user` WHERE `username`='$username'";
$action=mysql_query($query);
$data=mysql_fetch_array($action);
$passmd5=md5($password);
if ($data['password']==$passmd5)
{
$_SESSION['username']=$username;
$_SESSION['password']=$password;
if ($data[status]==1){
$data['0']="valid";
}
if ($data[status]==2) {
$data['0']="valid1";
}
return $data;
}
else
{
$data['0']="invalid";
return $data;
}
}
}
function logout()
{
session_destroy();
}
?>
The second and third warning are because
$data[status]
should be
$data['status']
There isn't enough information in the question to explain why you get the warning about session_start()
. You need to check more of the code to find where you're calling session_start()
before this.