Jump to content

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: me@email.com \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

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.