2uzhan.com
Advertisement
Now Place:2uzhan.com » Cookie Problem - PLEASE HELP!

Cookie Problem - PLEASE HELP!

PHP @ December 31, 1969   Views:0

I created a cookie and it worked today in the morning. I came back and it just stopped working all of a sudden. I don't remember changing any settings. If anybody can help, it would be greatly appreciated. I check my IE and it does not set the cookie even on page2, page3 and so on. I understand cookies don't get set on the page they got created. This is the code from my file:

<?php
if((!isset($_POST["txtUserId"])) || (!isset($_POST["txtPassword"])))
{
?>
<body background="..\Images\Backgrounds\backgroundImage.jpg">
<div align="left">
<pre>
<font size="1" color="black">
You must login to authenticate yourself. Press the back button on
your browser to go back. Thank you!
</font>
</pre>
</div>
<?php
exit;
}

$userId = $_POST["txtUserId"];
$password = $_POST["txtPassword"];

$dbServer = "localhost";
$dbUser = "";
$dbPasswd = "";
$dbPort = "3306";
$dbDatabase = "MyDomain";

$conn = mysql_connect("$dbServer:$dbPort", $dbUser, $dbPasswd);

if(!$conn)
{
die("Could not connect to database:" . mysql_error());
}

$rc = mysql_select_db($dbDatabase, $conn);

if(!$rc)
{
die("Could not select database:" . mysql_error());
}

$sql = "SELECT userId, password FROM tblAdmin WHERE userId = '$userId' AND password = '$password'";

$result = mysql_query($sql, $conn);
if(!$result)
{
die("Could not execute query:" . mysql_error());
}

$nrows = mysql_num_rows($result);

if($nrows == null)
{
?>
<body background="..\Images\Backgrounds\backgroundImage.jpg">
<div align="left">
<pre>
<font size="1" color="black">
You entered an incorrect userid and/or password. Please press the return
button to try again.
</font>
</pre>
</div>
<form method="post" action="Admin.php" name="frmFailedAuthentication" id="frmFailedAuthentication">
<input type="submit" value="Return" name="cmdClose" id="cmdClose">
</form>
<?php
exit;
}
else
{
if(!isset($cookie_name))
{
// Setting cookie for authorized user
$cookie_name = "auth";
$cookie_value = "ok";
$cookie_expire = time() + 1000000;
$cookie_domain = "127.0.0.1";
setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);
}
header("Location: http://127.0.0.1/Admin/adminMenu.php");
exit;
}
?>
</body>

--------------Solutions-------------

do a search here for register_globals.... you are trying to access your cookie vars wrong...

you may ask how so....?

and to that... I say, a search shall bring you the answer

Tags:
© 2018 2uzhan.com Contact