You are here: setcookie issue « PHP « IT news, forums, messages
setcookie issue

Posted by John Hinton on 03/27/05 08:41

Seems my old setcookie scripts are busted in php with globals off.

--begin code--------------------------
<?
if(isset($_POST[tpassword]))
{
setcookie ("writer", "$_GET[twriter]");
setcookie ("password", "$_POST[tpassword]");
}
$action = $_REQUEST['action'];
define (Login, 0);
define (Entrance, 1);
define (Continue_Campaign, 2);
define (Finish_Campaign, 3);

##### LOGIN PAGE
#######################################################################

function login(){
include ('config.php');

$query = "SELECT * FROM atable";
$result = mysql_db_query($DBName, $query, $Link) or
print ("Query Failed");

printf ("<center><form METHOD=\"post\"
ENCTYPE=\"multipart/form-data\" ACTION=\"%s?action=%d\">\n",
$PHP_SELF, Entrance);
echo "<table><tr><td>\n";
echo "Writer Name: </td><td><select name=\"twriter\" size=\"0\"
VALUE=\"$writer\">\n";
while ($row = mysql_fetch_array($result)) {
echo "<option value=\"" . $row[0] . "\">" . $row[0] . "\n";
}
echo "</select>";
echo "</td></tr><tr><td>Password: </td><td><INPUT TYPE=password
NAME=\"tpassword\" SIZE=10 VALUE=\"$password\"\n>";
echo "<tr><td colspan=\"2\"><INPUT TYPE=\"submit\" NAME=\"button\"
VALUE=\"Enter Reporter Area\"></td></tr>";
echo "</td></tr></table>";
echo "</center></form>";
---end code---------------------

When I run this, the cookies aren't transfered to the second action
switch on the first load, but if I hit reload, they appear. So, to the
user, they are presented with logging in twice unless they know this odd
trick.

Any ideas about how to make this work on the first time through? This is
driving me nuts on two sites at the moment.

Thanks,
John Hinton

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация