session problems

A

Anonymous

Guest
I have this script that uses sessions, and for some reasno it doesnt work. If I session_start();
session_register("passwd");
session_register("r_pass");
when i click on login, the script does nothing, as if global variables were off, but if i remove those 3 lines, the script works perfectly (and i need sessions in my script). Heres the script:

Code:
<?php

session_start();
session_register("passwd");
session_register("r_pass");

?>
<html>
<head>
  <title>Admin Login</title>
</head>

<body>


<?php

//start function "getpasswd();"

function getpasswd() {
?>
<form action = "admin.php" method = "post">
<b>Please enter the administrator's password:</b>
<p>
<input type = "text" name = "passwd">
<br>
<input type = "submit" value = "Login">


</form>

<?php

} 

// end function "getpasswd();"

 if(isset($passwd)) {
  //default password is "adminpass" check md5.php to make a new password
  $r_pass = "25e4ee4e9229397b6b17776bfceaf8e7"; 
  $passwd = md5($passwd);
  
  if($passwd != $r_pass) {
 
  ?>
  <b>Incorret password!</b>

  <?php  
  getpasswd();

  } //end if
  else {

  //main upload of image/description starts here
  
  ?>
   <center><b>Welcome admin!</b>
   <p>
   Upload the picture of the template, and its description below:
   <p>
  
   <form action = "upload.php" method = "post" enctype = "multipart/form-data">
   <input name="template_pic" type="file"><br>
   <br>
   Name of the template:<br>
   <input type = "text" name = "name"> <p>
   <input type = "submit" value = "Upload">
   </form>
  
   </center> 
 

  

  <?php
  //main upload of image/description ends here
  } //end else  

} //end if
else {

getpasswd();


 } //end else

?>

</body>
</html>

*note, upload.php isnt important, so i wont post it

Thanks, Nick
 
please read my article http://www.php-forum.com/p/viewtopic.php?t=1483

You should ALWAYS program thinking that register_globals is set to off.. no exceptions. In future releases there will not be an option to turn them on.
 
Back
Top