PDA

View Full Version : Notice: Undefined index with a setcookie



sWo0p
October 30th, 2005, 06:12 AM
ej guys.. strange thing.. i made myself a login script with a setcookie.. but somehow there is a strange error...

i test this script on my own php server it works fine.. but if i upload it to the webserver its suppose to go on, there is an error.. and i just cant seem to find what it is.. ???

index.php:



<?

include "login_config.php";

if(isset($_POST)){
foreach($_POST as $key => $val){
$$key = $val;
}
}


if(isset($submit) && $submit != ""){


if ($name == $corr_name && $pass == $corr_pass ) {


setcookie('login', $value, time()+900); //* 15min (900sec) *//
header("Location: $pagina");

} else {

echo "Eerst inloggen A.U.B of voer de goede gegevens in....";
exit;
}
}

?>

<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<center><font class="atentie_tekst">(Administrators hebben allen toegang hier..)</font></center>
<table border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td>Login:<br><INPUT TYPE="name" SIZE="15" NAME="name"><br></td>
<td>Paswoord:<BR><INPUT NAME="pass" TYPE="password" SIZE="15"><br></td>
</tr>
<tr>
<td><INPUT TYPE="submit" NAME="submit" VALUE="Login">&nbsp;<input type="reset" name="submit" value="Herstel"></td></td>
</tr>
</table>
</form>



login_config.php:



<?

$corr_name = "test";
$corr_pass = "test";

$pagina = "inhoud_pagina.php";

$value = 'true';


?>



inhoud_pagina.php



<?php

include "login_config.php";

if ($_COOKIE['login'] == true){

?>

hallo


<?

} else {

echo "<script LANGUAGE='javascript' TYPE='text/javascript'>window.location='$pagina'</script>";

}

?>


Error mssg:

Notice: Undefined index: login in .....inhoud_pagina.php on line 5 (keep kliking (looping))...

kan anyone help me.. ???

sWo0p
October 31st, 2005, 01:31 PM
bump.. is there no one that can help me?

Jacobxx
November 1st, 2005, 09:58 PM
hello, take out the include login_config.php on index.php and just put that info at the heading of your code and that fixes all problems for me.

http://jacbov.allhyper.com/test/

thats the quick fix.

sWo0p
November 2nd, 2005, 01:50 AM
nope does'nt work.. on one server (mine) it works fine but as soon as i uploadit to the website i need it oni get straks error again...

i think im beterof creating a newone.. thx for yuh help Jacob