Jump to content

Recommended Posts

I am trying to make it so people can reset there password but I am getting the same error every which way I try to change the code.

 

The form shows up but when you type in a email address and hit reset my password the this error comes up:

Fatal error: Call to undefined function escape_data() in /home/nayliner/public_html/datetiki/forgot_password.php on line 40

Which is:

$query = "SELECT user_id FROM users WHERE email='".  escape_data($_POST['email']) . "'";

 

Any help would be great

 

 

 

<?php
// Include the PHP script that contains the session information.
include('includes/session.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>The Date Tiki - Your Dating Resource</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="includes/base.css" title="Default" media="screen" />
<script type="text/javascript" src="includes/include.js"></script>

</head>

<body>

<?php include('includes/top.php'); ?>

<div id="main">

	<div id="sideBarLeft"><?php include('includes/left.php'); ?></div>

	<div id="content"><div class="innerContent">
		<div class="title">Change Password</div>
		<?php 				
			if (isset($_POST['submitted'])) { // Handle the form.

				require_once ('../../datemysql_connect.php'); // Connect to the database.

				if (empty($_POST['email'])) { // Validate the email address.
					$uid = FALSE;
					echo '<p><font color="red" size="+1">You forgot to enter your email address!</font></p>';
				} else {

					// Check for the existence of that email address.
					$query = "SELECT user_id FROM users WHERE email='".  escape_data($_POST['email']) . "'";		
					$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
					if (mysql_num_rows($result) == 1) {

						// Retrieve the user ID.
						list($uid) = mysql_fetch_array ($result, MYSQL_NUM); 

					} else {
						echo '<p><font color="red" size="+1">The submitted email address does not match those on file!</font></p>';
						$uid = FALSE;
					}

				}

				if ($uid) { // If everything's OK.

					// Create a new, random password.
					$p = substr ( md5(uniqid(rand(),1)), 3, 10);

					// Make the query.
					$query = "UPDATE users SET pass=SHA('$p') WHERE user_id=$uid";		
					$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
					if (mysql_affected_rows() == 1) { // If it ran OK.

						// Send an email.
						$body = "Your password to log into The Date Tiki has been temporarily changed to '$p'. Please log in using this password and your username. At that time you may change your password to something more familiar.";
						mail ($_POST['email'], 'Your temporary password.', $body, 'From: admin@thedatetiki.com');
						echo '<h3>Your password has been changed. You will receive the new, temporary password at the email address with which you registered. Once you have logged in with this password, you may change it by clicking on the "Password Change" link.</h3>';
						mysql_close(); // Close the database connection.
						//include ('./includes/footer.html'); // Include the HTML footer.
						exit();				

					} else { // If it did not run OK.

						echo '<p><font color="red" size="+1">Your password could not be changed due to a system error. We apologize for any inconvenience.</font></p>'; 

					}		

				} else { // Failed the validation test.
					echo '<p><font color="red" size="+1">Please try again.</font></p>';		
				}

				mysql_close(); // Close the database connection.

			} // End of the main Submit conditional.

			?> 
			<form action="forgot_password.php" method="post">
				<table border="0" cellpadding="0" cellspacing="5">
					<tr>
						<td>Email Address:</td>
						<td>
							<input type="text" name="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" />
						</td>
					</td>
					<tr colspan="2">
						<td>					
						<div align="center"><input type="submit" class="button" name="submit" value="Reset My Password" /></div>
						<input type="hidden" name="submitted" value="TRUE" />
						</td>
					</tr>
				</table>
			</form>

	</div>
		<div id="footer"><?php include('includes/bottom.php'); ?></div>
	</div>
</div>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/66225-solved-password-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.