-
[PHP]Lost Password
Hello,
i am making lost password form now it doesn't work no error nothing
hope anyone know a solution for it
PHP Code:
<?php
include("config.php");
if($_POST['Submit'] AND $_POST['username']){
$username = $_POST['username'];
$result = mysql_query("SELECT * FROM `users` where `username`='$username'");
while($row = mysql_fetch_array($result))
{
$email = $row['email'];
$message = '
Dear, '.$username.'
Your Password as requested !
Password : '.$row['password'].'
We hope you enjoy your time with us!
';
$headers = 'From: admin@aura.fakezone.nl' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, 'Your password!', $message, $headers);
$error = "Your information have been sended to : ".$email.".";
}} elseif(!$_POST['Submit']){
$error = "Error : Unkown information";
}
?>
<html>
<head>
<title>Aura Online </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {background-color:#19292A;}
table, td {font-family:Verdana, Tahoma; font-size:10px; color:#DDDDDD;}
a {color:#B5FFFF;}
a:hover {color:#80B7BA;}
.navhead {display: block; padding-left:4px; padding-right:4px; background-color:#405D5F; border: 1px solid #333333; text-align:center; font-weight: bold;}
</style>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen">
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="709">
<tbody>
<tr>
<td colspan="4"> <img src="images/index_01.gif" alt="" height="35" width="247"></td>
<td> <img src="images/index_02.gif" alt="" height="35" width="212"></td>
<td colspan="2"> <img src="images/index_03.gif" alt="" height="35" width="250"></td>
</tr>
<tr>
<td colspan="7"> <img src="images/banner.png" alt="" height="142" width="709"></td>
</tr>
<tr>
<td colspan="4"> <img src="images/index_05.gif" alt="" height="31" width="247"></td>
<td> <img src="images/index_06.gif" alt="" height="31" width="212"></td>
<td colspan="2"> <img src="images/index_07.gif" alt="" height="31" width="250"></td>
</tr>
<tr>
<td> <img src="images/index_08.gif" alt="" height="17" width="15"></td>
<td> <img src="images/index_09.gif" alt="" height="17" width="128"></td>
<td> <img src="images/index_10.gif" alt="" height="17" width="46"></td>
<td colspan="3"> <img src="images/index_11.gif" alt="" height="17" width="489"></td>
<td> <img src="images/index_12.gif" alt="" height="17" width="31"></td>
</tr>
<tr>
<td background="images/index_13.gif" height="126" width="15"> <img src="images/index_13.gif" alt="" height="126" width="15"></td>
<td background="images/navigation.gif" height="126" valign="top" width="128">
<div class="navhead">Menu</div>
<a href="index.php">Home</a><br>
<a href="login.php">Login</a><br>
<a href="register.php">Register</a><br>
<a href="chat.php">Chat Room</a><br>
<a href="contact.php">Contact Us</a><br>
<a href="forum.php">Forum</a><br>
<a href="downloads.php">Downloads</a><br>
<p><br>
</td>
<td background="images/index_15.gif" height="126" width="46"> <img src="images/index_15.gif" alt="" height="126" width="46"></td>
<td colspan="3" background="images/content.gif" height="126" valign="top" width="489"><div align="center">
<!-- Content Starts Here! -->
</div>
<div class="navhead">
<div align="center">Welcome!</div>
</div>
<p align="center">Lost password form :</p>
<form name="form1" method="post" action="">
<label>
<div align="center">
<input name="username" type="text" id="username" value="username">
</div>
<p align="center">
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</p>
<p align="center"> </p>
<p align="center">
<?php
if($error){
echo $error;
} ?>
</p>
</form>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"></td>
<td background="images/index_17.gif" height="126" width="31"> <img src="images/index_17.gif" alt="" height="126" width="31"></td>
</tr>
<tr>
<td> <img src="images/index_19.gif" alt="" height="75" width="15"></td>
<td> <img src="images/index_20.gif" alt="" height="75" width="128"></td>
<td> <img src="images/index_21.gif" alt="" height="75" width="46"></td>
<td colspan="3"> <img src="images/index_22.gif" alt="" height="75" width="489"></td>
<td> <img src="images/index_23.gif" alt="" height="75" width="31"></td>
</tr>
<tr>
<td> <img src="images/spacer.gif" alt="" height="1" width="15"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="128"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="46"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="58"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="212"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="219"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="31"></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
thanks in advanced !
-
Re: [PHP]Lost Password
running on own webserver ?(home webserver), if yes then the mail() function isn't supported
becouse you probaly not running an smtp server lol (like somebody is running that anyway lol)
-
Re: [PHP]Lost Password
In another thread, I put down what mailer I use.
http://www.phpguru.org/static/smtp.html
Works for me so far.
I have a linux server, and sendmail doesn't work properly for some reason... so I'm using that.
-
Re: [PHP]Lost Password
i tested mail part outside of this page than it works...
edit : got working one now
PHP Code:
<?php
include("config.php");
if($_POST['Submit'] AND $_POST['username']){
$username = $_POST['username'];
$result = mysql_query("SELECT `email`, `password` FROM `users` where `username`='$username' limit 1");
$row = mysql_fetch_array($result);
$newpass = rand (1000, 9999);
$sql = "update `users` set `password`=MD5('$newpass') where `username`='$username' limit 1";
mysql_query($sql);
$email = $row['email'];
$message = '
Dear, '.$username.'
Your Password as requested !
Password : '.$newpass.'
We hope you enjoy your time with us!
';
$headers = 'From: admin@aura.fakezone.nl' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email, 'Your password!', $message, $headers);
$error = "Your information have been sended to : ".$email.".";
} elseif(!$_POST['Submit'] AND !$_POST['username']){
$error = "Error : Unkown information";
}
?>
<html>
<head>
<title>Aura Online </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {background-color:#19292A;}
table, td {font-family:Verdana, Tahoma; font-size:10px; color:#DDDDDD;}
a {color:#B5FFFF;}
a:hover {color:#80B7BA;}
.navhead {display: block; padding-left:4px; padding-right:4px; background-color:#405D5F; border: 1px solid #333333; text-align:center; font-weight: bold;}
</style>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen">
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="709">
<tbody>
<tr>
<td colspan="4"> <img src="images/index_01.gif" alt="" height="35" width="247"></td>
<td> <img src="images/index_02.gif" alt="" height="35" width="212"></td>
<td colspan="2"> <img src="images/index_03.gif" alt="" height="35" width="250"></td>
</tr>
<tr>
<td colspan="7"> <img src="images/banner.png" alt="" height="142" width="709"></td>
</tr>
<tr>
<td colspan="4"> <img src="images/index_05.gif" alt="" height="31" width="247"></td>
<td> <img src="images/index_06.gif" alt="" height="31" width="212"></td>
<td colspan="2"> <img src="images/index_07.gif" alt="" height="31" width="250"></td>
</tr>
<tr>
<td> <img src="images/index_08.gif" alt="" height="17" width="15"></td>
<td> <img src="images/index_09.gif" alt="" height="17" width="128"></td>
<td> <img src="images/index_10.gif" alt="" height="17" width="46"></td>
<td colspan="3"> <img src="images/index_11.gif" alt="" height="17" width="489"></td>
<td> <img src="images/index_12.gif" alt="" height="17" width="31"></td>
</tr>
<tr>
<td background="images/index_13.gif" height="126" width="15"> <img src="images/index_13.gif" alt="" height="126" width="15"></td>
<td background="images/navigation.gif" height="126" valign="top" width="128">
<div class="navhead">Menu</div>
<a href="index.php">Home</a><br>
<a href="login.php">Login</a><br>
<a href="register.php">Register</a><br>
<a href="chat.php">Chat Room</a><br>
<a href="contact.php">Contact Us</a><br>
<a href="forum.php">Forum</a><br>
<a href="downloads.php">Downloads</a><br>
<p><br>
</td>
<td background="images/index_15.gif" height="126" width="46"> <img src="images/index_15.gif" alt="" height="126" width="46"></td>
<td colspan="3" background="images/content.gif" height="126" valign="top" width="489"><div align="center">
<!-- Content Starts Here! -->
</div>
<div class="navhead">
<div align="center">Welcome!</div>
</div>
<p align="center">Lost password form :</p>
<form name="form1" method="post" action="">
<label>
<div align="center">
<input name="username" type="text" id="username" value="username">
</div>
<p align="center">
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</p>
<p align="center"> </p>
<p align="center">
<?php
if($error){
echo $error;
} ?>
</p>
</form>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"></td>
<td background="images/index_17.gif" height="126" width="31"> <img src="images/index_17.gif" alt="" height="126" width="31"></td>
</tr>
<tr>
<td> <img src="images/index_19.gif" alt="" height="75" width="15"></td>
<td> <img src="images/index_20.gif" alt="" height="75" width="128"></td>
<td> <img src="images/index_21.gif" alt="" height="75" width="46"></td>
<td colspan="3"> <img src="images/index_22.gif" alt="" height="75" width="489"></td>
<td> <img src="images/index_23.gif" alt="" height="75" width="31"></td>
</tr>
<tr>
<td> <img src="images/spacer.gif" alt="" height="1" width="15"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="128"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="46"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="58"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="212"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="219"></td>
<td> <img src="images/spacer.gif" alt="" height="1" width="31"></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>