1 Replies - 1299 Views - Last Post: 24 December 2012 - 04:19 AM Rate Topic: -----

#1 irsilly   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 13-May 12

Reset password form not showing up

Posted 23 December 2012 - 10:46 PM


I am making a forgot password page for my login system and my form is not showing up. I checked everything and can't seem to find the mistake. I'm sure its a stupid little one but can't seem to find it. Can anybody help? Code below.


error_reporting (E_ALL ^ E_NOTICE);
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
<!DOCTYPE html>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Member System - Login</title>
	if(!$username && !userid){
		echo "<form action='./forgotpass.php'>
			<td><input type='text' name='user' /></td>
			<td><input type='text' name='email' /></td>
			<td><input type='submit' name='resetbtn' value='Reset Password' /></td>
		echo "Please logout to view this page.";

Also, I forgot to mention, that it is showing my 'else' statement when I reload my page meaning its just showing me a message of "Please logout to view this page"

Is This A Good Question/Topic? 0
  • +

Replies To: Reset password form not showing up

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Reset password form not showing up

Posted 24 December 2012 - 04:19 AM


Look at the second condition: !userid. You are missing the $ in front of the variable, which means that PHP is assuming it was meant to be the string "userid", which will never evaluate as false. And thanks to your error_reporting call at the top of your page, where you tell it to hide notices, the notice PHP would print to let you know about this never shows.

You should always develop code with error reporting fully enabled, so that you see any and all errors and notices, and then deal with them. Hiding notices instead of fixing them is just asking for trouble. - Presumably you do it because of the way you handle the session variables: copying them to variables without making sure they exist, thus causing undefined index notices, and then checking the value of the variables. That is not a good way to do that. Instead, you should be using functions like empty() or isset() to check the session variables.

Instead of doing this:
$var1 = $_SESSION["var1"];
$var2 = $_SESSION["var2"];
if (!$var1 && !$var2) {


Do this:
if(!empty($_SESSION["var1"]) && !empty($_SESSION["var2"])) {


Now you can enable the warnings again, so you'll be able to see other warnings that you may not be expecting, like the one I mentioned before.

By the way, I moved this thread to the PHP forum. This isn't really a problem with the HTML or CSS.

This post has been edited by Atli: 24 December 2012 - 04:21 AM

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1