i have this code, and i’m trying to create a session in order to get user’s gallery id..
The problem is, if i use $_SESSION[‘username’] it works, but like this not… can you please check what’s wrong with this?
Thanks!
mysql_connect($host, $user, $pass);
mysql_select_db($database);
$username = mysql_real_escape_string($_POST['username']);
$password = md5($_POST['password']);
$result = mysql_query("SELECT * FROM $table WHERE username = '$username' AND password = '$password'
");
while ($rows = mysql_fetch_array($result)) {
if(mysql_num_rows($result))
{
$rows['gal_id']=$gal_id;
session_start();
$_SESSION['gal_id'] = htmlspecialchars($gal_id);
}
else
{
// Invalid username/password
echo '<p><strong>Error:</strong> Invalid username or password.</p>';
}
change this:
to
EDIT: i dont think it need a furhter explanation