Skip to main content
hjohnson2011
Participant
June 7, 2011
Question

Forget Password Page

  • June 7, 2011
  • 1 reply
  • 350 views

I have all ready set up a user_registration table that contains the information that I am trying to retrieve. Nonetheless, the send_password_ac.php is unable to locate the email address in the database that is in the database. I have created a forget the forgot_password.php (search page not shown) and I have created the send_password_ac.php (results page) see below:

//Connect to server and select databse.

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

mysql_select_db("$db_name")or die("cannot select DB");

// value sent from form

$register_pemail_to=$_POST['register_pemail_to'];

// table name

$tbl_name="user_registration";

// retrieve password from table where email = $register_pemail_to…

$sql="SELECT register_pass FROM $tbl_name WHERE register_pemail='$register_pemail_to'";

$result=mysql_query($sql);

// if found this e-mail address, row must be 1 row

// keep value in variable name "$count"

$count=mysql_num_rows($result);

// compare if $count =1 row

if($count==1){

$rows=mysql_fetch_array($result);

// keep password in $your_password

$your_password=$rows['register_pass'];

When the code is run what I get in return is “Could not find email in database. Please try again”. So, I know I am able to connect to the database but what I don’t get is why it is not able find email field (register_pemail) in the database. Any help would be appreciated.

hjohnson2011

This topic has been closed for replies.

1 reply

June 8, 2011

I can't comment on why you're not retrieving email from your query because you have not provided enough information regarding the issue.

I can comment on the code you have provided though. Basically, it's unsecure. You might as well be posting your database username and password on your website with big red letters in 60px font that says hey everybody, go ahead and hack my database. Fix the vulnerabilities of injection attack in your query.

If you were using Dreamweaver to produce your query then you would be protected against injection attacks in your query... You're in the Dreamweaver forum asking Dreamweaver questions, aren't you? Try using Dreamweaver then, just a suggestion.

hjohnson2011
Participant
June 8, 2011

Got it!