forgot password script

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

forgot password script

Post by fariquzeli »

I'm working on making a simple page that emails members their passwords if they forget them. (After they put their email in a form and hit submit)

I'm really trying to figure this one out on my own, so for now i just want to print the search result (which will be the user's password) from a fairly simple mysql query. Now, this isn't how I'm going to actually do this. I just want to know that i'm retrieving the data from the db correctly. This is the code I came up with, the form self submits, and it is echoing out "resource ID # 3", and I have no idea why it would do this. Here's the php code atop the self-submitting form

Code: Select all

<?php
include("webvars.php");

if (isset($submit)) &#123;
	mysql_connect($hostname, $user, $pass)
	or die ("the site database is down.");
	mysql_select_db("pancorp");
	
	$sql = "SELECT password FROM technicians WHERE email = '$email'";
	$result = mysql_query($sql) or die("The database is down.");
	
	$getresult = mysql_query($sql);	
	
	echo ("$getresult");
&#125;
?>
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

One way you could help yourself is to try this:

Code: Select all

<?php
include("webvars.php");

if (isset($submit)) &#123;
   mysql_connect($hostname, $user, $pass)
   or die ("the site database is down.");
   mysql_select_db("pancorp");
   
   $sql = "SELECT password FROM technicians WHERE email = '$email'";
   $result = mysql_query($sql) or die("The database is down.");
   // Add this
   echo $sql;

   $getresult = mysql_query($sql);   
   
   echo ("$getresult");
&#125;
?>
That will output the actual SQL statement to your browser. Put it natively into your database to see the exact results you will get with the SQL statement.
I have a similar script written for the forgot password so if you still have trouble let me know and I can probably help you more.

Direwolf
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

This is what I get outputted to the browser:

SELECT password FROM technicians WHERE email = 'ttoomey@yiinc.com'Resource id #3

so the form is all configurd properly, but i'm still getting that weird resource id #3 <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>. Any ideas?
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Throw this in after the $result = statement:

Code: Select all

die("Get_results =".$getresult);
to make sure that echo($getresult) statement outputs what you think it is outputting.
I am thinking that it is where the Resource thing is coming from.

Direwolf
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can't get the results straight from mysql_query() you have to go one step further and use mysql_fetch_assoc/array/row depending on your needs.

Code: Select all

<?php
$result = mysql_query($sql) or die(mysql_error());
$info = mysql_fetch_assoc($result);
echo $info&#1111;'password'];
?>
Should work a bit better.

Mac
Post Reply