PDA

View Full Version : Fixed - MySQL - newbie needs help...


STouraine
3-24-06, 05:15 PM
Hi all,

I’m trying to use a small script with a MySQL database, the aim is to store Username / email / Passwords in this database and to allow users to ask for lost password thanks to their email.
I found this script on internet and I’m trying to adapt it for my needs, unfortunately the script mdp_perdu.php always returns a message saying that the email is invalid (Tried with cosetta@pictur.net which well exists in the database).

Here is the code, I assume there is something wrong around lines 28 / 30, if anybody could help I would sincerely appreciate!

Full script installed here: http://pictur.net/tools/LostPassword/

Many thanks.
Stéphane.

EDIT : Variables should be entered here...
mysql_connect('host SQL', 'login SQL', 'mot de pass SQL');
mysql_select_db('nom de votre base');


<? if(empty($email)){?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Vous
avez oubli&eacute; votre mot de passe ?<BR>
Entrer simplement l'adresse e-mail utilis&eacute; lors de votre inscription
&agrave; notre zone membre,<br>
votre mot de passe vous sera alors envoyer &agrave; cette m&ecirc;me adresse
! </font> </div>
<form ACTION="mdp_perdu.php">
<div align="center">
<input type=text name=email SIZE="50">
<br>
<INPUT TYPE="submit" NAME="Submit" VALUE="Envoyer">
</div>
</form>

<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">[
<a href="conection.php">Se conecter</a> ]</font><br>
<? }else{
mysql_connect('host SQL', 'login SQL', 'mot de pass SQL');
mysql_select_db('nom de votre base');
$query = mysql_query("SELECT pseudo, passe, email FROM annuweb_membre WHERE email='$email'");

if (list($pseudo, $passe, $email) = mysql_fetch_array($query)){
$mail=mail("$pseudo <$email>", "Votre mot de passe VotreSite.com","Bonjour,\n\nVous avez demander à recevoir votre mot de passe.\nVotre mot de passe est : $passe\n\nCordialement, le webmaster.\nhttp://www.votresite.com", "From: VotreSite.com <vous@votresite.com>");
if($mail)echo"\n\nVotre mot de passe vien de vous être envoyer à l'adresse : $email!<br>\n\nVous allez recevoir d'ici quelques instants, votre mot de passe.<br>";
else echo"Le mot de passe ne peux vous être envoyer!<br>Renouveller votre demande dans un instant.<br>";
} else echo"Vous avez entré une adresse e-mail invalide!";
}?>
</div>
</body>
</html>

satis
3-25-06, 03:20 PM
your script assumes that global variables are turned on, and they are not. I'm not to clear what the if statement does (never used list) but the sql query is wrong. Right before the if(empty($email)) I would put:

$email = $_POST['email'];

so instead of
<? if(empty($email)){?>
put
<?$email = $_POST['email'];
if(empty($email)){?>