Jump to content

Change password...not working o.O...


The14thGOD

Recommended Posts

I have this code on other sites and when I put it on another site it doesnt work. I changed everything to adjust so the variables work. Here's the code:

<?php
if ($_GET['task'] == 'send') {
	$error = 'true';
	include("includes/include_connect_db.php");
	$query = "SELECT * FROM user WHERE personal_email='$email' ";
	if (mysql_query($query)) {
		$error = 'false';
		include("includes/include_random_gen.php");
		$new_pw = get_rand_id(7);
		$newpassword = md5($new_pw);
		$query = "UPDATE user SET password='$newpassword' WHERE personal_email='$email' ";
		if (mysql_query($query)) {
			//do this
			mail("$email" , "Password Reset for: site.com" , $body, "From: [email protected] \r\n");
		}
	}else{
		$error = 'true';
	}
}
if (mysql_error()) {
	echo (mysql_error());
}
?>

Now it gets all the way to the point of emailing...and i recieve an email but the password doesnt reset...anyone see what im missing o.O?

 

***edit***

so i just found out my first query isn't working right, ive been puttin in a wrong email and it still goes through everything...

Link to comment
https://forums.phpfreaks.com/topic/62959-change-passwordnot-working-oo/
Share on other sites

ok, so the code works except for the first line of the query:

 

<?php
include("includes/include_connect_db.php");
	$query = "SELECT * FROM user WHERE personal_email='$email' ";
	if (mysql_query($query)) {?>

 

so basically...it's getting into that if statement even if the email entered is not in the database...

heres what you can do first do this

 

$query = "SELECT * FROM user WHERE personal_email='$email' ";

print_r(mysql_fetch_array(mysql_query($query)));

 

that will show you why because maybe if the everything is good

and maybe the $email is empty and maybe that matches in your db

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.