Jump to content

Hybride

Members
  • Posts

    286
  • Joined

  • Last visited

Everything posted by Hybride

  1. Unfortunately, none of the edits work, arrow. I do sincerely apologise if am or this code is being irritating.  :-\
  2. Redarrow, you are correct on all of the code parts. And akitchin, I did as you said, and updated the code a bit. Unfortunately, even with the mysql_error() added, it is still the same problem. Am thinking it may be the (if($email) == $row['pass']), but am not sure if it is, or what to change it to. [code]<center><b><p>Forgot Password</p></b></center> <p>Enter the email you used when registered to the site.</p> <form method="post" action="../client/forgot_pass.php"> <table border="0" cellpadding="3" cellspacing="1" > <tr> <td><b>Email: </b></td> <td> <input name="email" type="text" size="25" maxlength="50"><br /> <input type="submit" name="submitted" value="Reset Password"></p> <? $login =  $_POST['login']; $email = $_POST['email']; $pass = $_POST['pass']; $temppass = $_POST['temppass']; $client_id = $_POST['client_id']; if (isset($_POST['submitted'])) { $errors = array(); if (empty($email)) { $errors[] = print '<p><b>Error:</b> Please enter your email.</P>'; } else { $email = trim($email); $query = "SELECT client_id, pass FROM client WHERE email='$email'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array ($result, MYSQL_ASSOC); if ($row) { $row['pass']; $row['email']; $row['client_id']; } else { $errors[] = print '<p><b>Error:</b> Email submitted does not match those on file.</p>'; } } if ($email == $row['pass']) { $pass = substr ( md5(uniqid(rand(),1)), 3, 10); $query = "SELECT client_id, email FROM client WHERE email='$email'"; $result = mysql_query ($query) or die(mysql_error()); $num = mysql_num_rows($result); if (mysql_num_rows($result) == 1) { $query = "UPDATE client SET pass=PASSWORD('$pass') WHERE email='$email'"; $result = mysql_query ($query); if (mysql_affected_rows() == 1) { echo '<p>Your password has been changed. An email has been sent to your account.</p>'; exit(); $body = "Your password has been temporarily changed to '$pass'."; $body .= "You may login using this password, and upon login, change it.\r\n"; $body .= "Support at Electronic Commerce, Inc."; mail ($email, 'Your temporary password.', $body, 'From: support@electronic-commerce.us.com'); } else { $errors[] = print '<p><b>Error:</b> Your password could not be changed due to a system error.</p>' . mysql_error(); } mysql_close(); } else { $errors[] .= print '<p>Please try again.</p>'; } } } ?> </form> </td> </tr> </table>[/code] Thank you again for helping!
  3. That is the main problem, yes. The UPDATE query doesn't seem to respond with updating the password, nor confirming that it has been updated and no email has been sent.
  4. Actually, what am getting is everything *but* the update. The errors are all correct - they all show up when something is done wrong. However, when the correct email is put in, it doesn't show up/register. And I've tried the $row['pass'] and unfortunately, doesn't work. Thanks for the tip, though. :)
  5. Did you install using IIS 4+ on the PHP installer? And from the looks of the page, are you actually running a MS 2003 server?
  6. I do apologise before hand if there is a script like this or if am just generally irritating. I've been staring at this script for two days now, and I can't figure out what's wrong with it. My problem deals with the "reset_pass.php" script. It's half taken from a book, half editted to my specs. I'm currently running PHP 4.4 I do believe so on the server. Now, the problem that am having is that everything works with the error part of the script - i.e.: if incorrect or incomplete email is typed, the error states it. However, if is a correct email, then the page just reverts back to itself (meaning, the script shows up, but no confirmation is stated or email sent.) [code]<? ob_start(); session_start(); DEFINE ('DB_USER', 'xxx'); DEFINE ('DB_PASSWORD', 'xxx'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'main'); $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL:' . mysql_error() ); @mysql_select_db (DB_NAME) OR die ('Could not select the database:' . mysql_error() ); ?> <center> <? include ("../themes/eventures/header.php"); include("../topmenu.php"); include("../leftmenu.php"); ?> <center><b><p>Forgot Password</p></b></center> <p>Enter the email you used when registered to the site.</p> <form method="post" action="../client/forgot_pass.php"> <table border="0" cellpadding="3" cellspacing="1" > <tr> <td><b>Email: </b></td> <td> <input name="email" type="text" size="25" maxlength="50"><br /> <input type="submit" name="submitted" value="Reset Password"></p> <? $login =  $_POST['login']; $email = $_POST['email']; $pass = $_POST['pass']; $temppass = $_POST['temppass']; $client_id = $_POST['client_id']; if (isset($_POST['submitted'])) { $errors = array(); if (empty($email)) { $errors[] = print '<p><b>Error:</b> Please enter your email.</P>'; } else { $email = trim($email); $query = "SELECT client_id, email FROM client WHERE email='$email'"; $result = mysql_query($query); $row = mysql_fetch_array ($result, MYSQL_ASSOC); if ($row) { $row['pass']; $row['email']; $row['client_id']; } else { $errors[] = print '<p><b>Error:</b> Email submitted does not match those on file.</p>'; } } if ($email == $row[pass]) { $temppass = substr ( md5(uniqid(rand(),1)), 3, 10); $temppass = $pass; $query = "SELECT client_id, email FROM client WHERE email='$email'"; $result = mysql_query ($query); $num = mysql_num_rows($result); if (mysql_num_rows($result) == 0) { $row = mysql_fetch_array ($result, MYSQL_NUM); $query = "UPDATE client SET pass=PASSWORD('$temppass') WHERE email='$email'"; $result = mysql_query ($query); if (mysql_affected_rows() == 1) { print '<p>Your password has been changed. An email has been sent to your account.</p>'; exit(); $body = "Your password has been temporarily changed to '$temppass'."; $body .= "You may login using this password, and upon login, change it.\r\n"; $body .= "Support at Electronic Commerce, Inc."; mail ($email, 'Your temporary password.', $body, 'From: support@electronic-commerce.us.com'); } else { $errors[] = print '<p><b>Error:</b> Your password could not be changed due to a system error.</p>' . mysql_error(); } mysql_close(); } else { $errors[] .= print '<p>Please try again.</p>'; } } } ?> </form> </td> </tr> </table> <? include ("../footer.php"); ?> </center>[/code] Am not certain, but could it be the update query? Any help would be greatly appreciated.
×
×
  • 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.