Jump to content

Problem with "remind me of my password" PHP page


Johns3n

Recommended Posts

Hi again, people at PHPfreaks.com :)

 

I'm in abit of a kurfuffel with a page i wrote that is suppose to remind you of your user information, in case you forgot it.. but some strange reason it will not parse at all, and error reporting doesn't work either.. so im hoping that some of you maybe can see where i am wrong? as i am afraid i have stared myself blind looking for the error :(

 

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

include('../config.php');

// Check if the user already entered their email
$mailed = mysql_real_escape_string($_GET['mailed']);

// If the user already entered their email, begin processing it
if ($mailed == "yes")
{
// Get email from form
$email = mysql_real_escape_string($_POST['email']);

// Define SQL query to see if the user exist
sql = "SELECT * FROM ".$db_prefix."users WHERE email = '".$email."'";

// Execute SQL query
$result = mysql_query($sql);

// Mysql_num_row is counting the returned table rows
$count = mysql_num_rows($result);

// If 1 user is found create a email
if($count >= 1)
{
	// Create a mail containing the information
	while($row = mysql_fetch_assoc($result))
	{
		$modtager = "" . $row['email'] . "";
		$emne = "Username and Password reminder";

		$besked = "You recently requested your username and/or password information for your user on the website: ".$site_url."\n
		\n
		\n
		Username: " . $row['username'] . "\n
		Password: " . $row['password'] . "\n
		\n
		\n
		After your first login, you should change your password again for security measures. It's not required, but strongly recommended.
		\n
		Best regards from:\n
		" .$site_url. "
		";

		$header = "from:Lörk(source)";
	}
	// Send the email with the username/password in it
	mail($modtager, $emne, $besked, $header);

	// Show a mail succesfully sent message
	echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
	<html xmlns='http://www.w3.org/1999/xhtml'>

	<head>
	<title>Lörk(source) - Forgot your usename and/or password?</title>
	<meta name='Robots' content='NOINDEX' />
	<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
	<link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' />
	</head>

	<body>
		<div id='wrapper'>
			<div id='login_form'>
				<p>An email containing your user information have been sent to your e-mail</p>
				<form action='remind.php?mailed=yes' method='post'>
					<p>Please enter the your e-mail tied to your user:</p>
					<p><input name='email' type='text' class='email'/></p>
					<p><input name='submit' type='submit' value='Login' /></p>
				</form>
			</div>
		</div>
	</body>
	</html>
	";
}
else
{
	echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
	<html xmlns='http://www.w3.org/1999/xhtml'>

	<head>
	<title>Lörk(source) - Forgot your usename and/or password?</title>
	<meta name='Robots' content='NOINDEX' />
	<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
	<link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' />
	</head>

	<body>
		<div id='wrapper'>
			<div id='login_form'>
				<p>No user with that email was found in the database, make sure you entered the correct e-mail</p>
				<form action='remind.php?mailed=yes' method='post'>
					<p>Please enter the your e-mail tied to your user:</p>
					<p><input name='email' type='text' class='email'/></p>
					<p><input name='submit' type='submit' value='Login' /></p>
				</form>
			</div>
		</div>
	</body>
	</html>
	";
}		
}
else
{
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>

<head>
<title>Lörk(source) - Forgot your usename and/or password?</title>
<meta name='Robots' content='NOINDEX' />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' />
</head>

<body>
	<div id='wrapper'>
		<div id='login_form'>
			<form action='remind.php?mailed=yes' method='post'>
				<p>Please enter the your e-mail tied to your user:</p>
				<p><input name='email' type='text' class='email'/></p>
				<p><input name='submit' type='submit' value='Login' /></p>
			</form>
		</div>
	</div>
</body>
</html>
";
}

?>

 

If you have any questions regarding the code, please just ask and il do my best to answer :)

thanks in advance

This line

sql = "SELECT * FROM ".$db_prefix."users WHERE email = '".$email."'";

needs a $ before it ;)

 

I told you i had looked myself blind on the problem :) thanks alot mate... thought i was past those dumb mistakes :P but obviously not :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.