Jump to content

Cookies, a simple problem gone wacky.


roper22

Recommended Posts

Hi everyone. I'm kinda new to PHP, but I feel as though I am learning quite quickly. I was attempting to make a login, but I hit a roadblock in this...

 

--------------------------------------------------------------

<?php

setcookie("cookie", "Hello.", time()+3200);

?>

--------------------------------------------------------------

 

 

 

That code works.

 

 

 

 

 

 

 

 

---------------------------------------------------------

<?php

include 'connect.php';

 

$password = $_POST['password'];

$username = $_POST['username'];

 

$sql = "SELECT * FROM users

WHERE username = '".$username."'

AND password = '".md5($password)."'";

 

$result = mysql_query($sql);

$num = mysql_num_rows($result);

 

if ($num > 0) {

//USER AND PASS ARE CORRECT

$id = mysql_fetch_array($result);

echo "s";

setcookie("cookie", "Hello.", time()+3200);

} else {

echo "f"; }

?>

---------------------------------------------------------

 

 

 

But after taking that EXACT line, and putting it in my login script, it doesn't work.

 

Help appreciated! Thanks tons guys.

 

 

The first code can be seen active on www.trportfolio.net/cookie_test.php

 

The second can be seen if you register at www.trportfolio.net/register.php and then login at www.trportfolio.net/login.php

Link to comment
https://forums.phpfreaks.com/topic/70536-cookies-a-simple-problem-gone-wacky/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.