Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

session problems

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

session problems

Postby nick_k » Mon Feb 24, 2003 8:00 am

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: Select all

<?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
nick_k
New php-forum User
New php-forum User
 
Posts: 34
Joined: Wed Dec 25, 2002 6:04 am
Location: The Netherlands

Postby Redcircle » Mon Feb 24, 2003 8:06 am

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.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron