When I submit the following from code, I have to refresh before the session vars $UNAME and $PASS are updated? how can I fix the code this doesnt occur?
index.php:
<?php
session_start();
if (!session_is_registered('UNAME')) {
session_register("UNAME");
}else
{
echo "uname=".$UNAME."<BR>";
}
if (!session_is_registered('PASS')) {
session_register("PASS");
}else
{
echo "pass=".$PASS."<BR>";
}
include "login.php";
?>
login.php:
<?
function showlogin($username="", $password="") {
?>
<FORM ACTION="<?$PHP_SELF?>" METHOD="Post">
Username:<INPUT TYPE=text NAME=username VALUE="<?echo $username?>">
<BR>
Password:<INPUT TYPE=text NAME=password VALUE="<?echo $password?>">
<BR>
<INPUT TYPE="submit" VALUE="login">
</FORM>
<?
}
$UNAME=$username;
$PASS=$password;
if(!isset($UNAME)||!isset($PASS)) {
showlogin();
}
else
{
$passwd="test";
if ($PASS==$passwd)
{
echo "logged in<BR>";
}
else
{
echo("There was problem with your username or password<BR>");
showlogin($UNAME,$PASS);
}
}
?>