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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.