Jump to content

attempting to set cookies


jlewis85

Recommended Posts

So I been at this for the last week or so and I have been having issues trying to get my cookies to set.

<?php
require_once('../Config/NFM-Functions.php');
require_once('../Config/browser.php');
$user=$_POST['username'];
$pass=$_POST['password'];
$ErrorCode=$_REQUEST['ErrorCode'];
switch ($_POST["action"])
{
	case Login:
	DB_Connection();
	ob_start();
	$SQLQ="SELECT * FROM `users` WHERE usern='$user'";
	$SQLR=mysql_query($SQLQ)or die("I am sorry there seems to be a problem with retrieving the user's details. This is the error that is given to me: \n\n".mysql_error()."\n\n - Charlie");
	while($SQLO = mysql_fetch_array($SQLR, MYSQL_ASSOC))
	{
   			if ($SQLO['pass'] = $pass) 
   				{   
   					setcookie('MYA_UID', $SQLO[uid]);  
        			setcookie('MYA_Active', "Yes");  
        			header("Refresh: 5; url=../");
   				}
   				else
   				{
   					header("Location: ?ErrorCode=1003"); 
   				}
   				break;
	}
}

?>
<html>
<head>
<title>MYAdvantage - NFM - Home Entertainment - Log On</title>
<?
if ( ( browser_detection( 'browser' ) == 'msie' ))
{
echo "<link rel=\"stylesheet\" href=\"../CSS/home-ie.css\">";
}
else
{
	echo "<link rel=\"stylesheet\" href=\"../CSS/home.css\">";
}
?></head>
<body>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="middle">
<center>
<table width="250" height="150" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="250" height="150" style="border: 2px #666666 solid; color: #4f74a1; font-weight: bold">
<center>
<?
switch ($_POST["action"])
{
	case Login:
	Echo "Log On Successful <BR><BR>Thank you ".$user.", for logging in. You will be redirected to the homepage.<br><br>";
	echo $_COOKIE;
	break;
	default:
	Echo "Log into MYAdvantage";
	echo  "<br><BR><font color=\"red\">";
	Error_Processor($ErrorCode);
	echo "</font>";
	ShowLogon();
	break;
}
?>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

 

Any ideas on what I am doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/134713-attempting-to-set-cookies/
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.