PHP $POST AND COOKIES NOT WORKING - CONFIG?
Posted by: Wessel (---.3g.vodacom.co.za)
Date: January 24, 2008 07:15PM

I am new to WAMP
Here is my two scripts

1.

//Check if cookie is set
if (!isset($_COOKIE['cookie_info']))
{
echo $_COOKIE['cookie_info'];
?>

<body>
<form method="POST" action="startresponse.php">
<br><br><br><br>
<table>
<tr>
<td width="433" style="border-style:none; border-width:medium; " colspan="2" align="center">
<img border="0" src="tawatifinal.gif" width="148" height="101"></td>
<td width="174" style="border-style: none; border-width: medium">
&nbsp;</td>
</tr>
</table>
<br>
<center><h1><font color= #800000 >Login</h1>
<Center>
<table border="0" width="auto">



<tr>
<td width="33%"><font color= #800000 >Login Name</td>
<td width="33%"><input type="text" name="name" size="20"></td>
<td width="34%"> </td>
</tr>
<tr>
<td width="33%"><font color= #800000 >Password</td>
<td width="33%"><input type="password" name="pass" size="20"></td>
<td width="34%"><input type="checkbox" name="set" value="ON">Remember Me</td>
</tr>
</table>
<center>
<p><input type="submit" value="Submit" name="sub">
<input type="reset" value="Reset" name="res"></p>
</center>
</body>
</form>
<?php }
else
{
//Cookie is set and display the data
$cookie_info = explode("-", $_COOKIE['cookie_user']); //Extract the Data
$name = $cookie_info[0];
$pass = $cookie_info[1];
echo "<center><h3>Welcome back $name and your password is $pass";
echo "<a href='startexit.php'>Logout</a>";
exit;
}
?>

2.
<?php
if(empty($_POST['name']) || empty($_POST['pass']))
{ ?>
<b>Fill All Details </b>
<?php exit;
}
else
{
//Colllect the details and validate
$time = time();
$name = $_POST['name'];
$pass =md5($_POST['pass']);
$check = $_POST['set'];

It does not pass the variable name pass and set ?

Options: ReplyQuote
Re: PHP $POST AND COOKIES NOT WORKING - CONFIG?
Posted by: Azrane (---.dhcp.insightbb.com)
Date: January 24, 2008 10:46PM

I'm seeing a number of issues that both pertain to your issues and don't.

1
if (!isset($_COOKIE['cookie_info']))
{
echo $_COOKIE['cookie_info'];


* You have the if-then flow set so the only way you'll hit the echo request for cookie_info is if the Cookie_info cookie isn't set. That will throw an exception.

* You shouldn't have PHP exit() when ending your script normally. This is forcing it to stop and exit suddenly. You should reserve this usage for error-checking and such.

2.

* Again, don't use the exit() function in this manner.

* You may want to use a stronger encryption for passwords. It's rather trivial to crack MD5.

Can't really tell what's going on with your variables by this info alone. Could you throw the following into your pages and post your results (masking your password of course)?
echo "<pre>";
print_r($_COOKIE);
print_r($_POST);
echo "</pre>";



Edited 1 time(s). Last edit at 01/24/2008 10:50PM by Azrane.

Options: ReplyQuote
Re: PHP $POST AND COOKIES NOT WORKING - CONFIG?
Posted by: Wessel (---.3g.vodacom.co.za)
Date: January 28, 2008 10:30AM

I included the code only received reply

Fill All Details echo "
";
print_r($_COOKIE);
print_r($_POST);
echo "
";

This code works with an online version - now I want an offline version on standalone pc - so that's why I thought maybe it has something to do with user setup or some config. It does not create or write anything to cookie and does not post.

Options: ReplyQuote
Re: PHP $POST AND COOKIES NOT WORKING - CONFIG?
Posted by: rip_pit (---.w82-125.abo.wanadoo.fr)
Date: January 29, 2008 05:57PM

you have to use full php tag opening.

Make sure you don't use <? instead of <?php else php tags won't be executed. This is why you get the php strings in output and not the values.

<?php
echo "<pre>";
print_r($_COOKIE);
print_r($_POST);
echo "</pre>";
?>

---------------------------------------------
XP SP3 - pIV - 3.2Ghz - 1.5Go de ram - Wamp 2.0

Options: ReplyQuote


Sorry, only registered users may post in this forum.