Jump to content

[SOLVED] need help on sending new password to email


pixeltrace

Recommended Posts

guys,

 

i need help, i have a form that lets the user reset there password and send a copy of the new pasword to there email

the form is already working except that the password that is being sent is also in a md5 format.

 

how do i fix this?

this is the current code of my page.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>:: JobHiRings :: Administration Page</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" background="images/headerbg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="226" align="left"><img src="images/header.gif" width="226" height="148"></td>
        <td> </td>
        </tr>
    </table></td>
    <td background="images/headerbg.gif"><img src="images/headeright.gif" width="16" height="148"></td>
  </tr>
  <tr>
    <td width="16" rowspan="2" align="left" valign="top" background="images/left.gif"><img src="images/left.gif" width="16" height="14"></td>
    <td width="745" align="center" valign="top"><table width="739" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="739"> </td>
        </tr>
        <tr>
          <td align="center"><h1 class="text4">Forgot Password</h1>
<span class="text8">A new password will be generated for you and send to the email address<br>
associated with your account, all you have to do is enter your
email address below.</span><br>
<br>
<?php session_start();
include 'db_connect.php';
$query="SELECT email, password FROM admin_user where email='$email'";
$result=mysql_query($query);

while($rec=mysql_fetch_assoc($result)){
$mail=$_SESSION['email']=$rec['email'];
}

if(mysql_num_rows($result)==1){

$password=md5($password);

if($_GET['cmd']=="update"){

$query2="UPDATE admin_user set `password`='$password' where
`email` = '$email' ";

$result=mysql_query($query2)or die(mysql_error());

$Message = 'please keep this new password in a safe place \n';
$Message = 'Your new password is: '.$password.'\n\n';

$Header = "webadministrator@jobhirings.com";
$To = "$email";
$Subject = "Your New Password"; 

mail($To,$Subject,$Message,"From: $Header");

echo " <div align='center'><b class='text3'>Thank you password changed!<br>
We have sent a copy to your email address!<div></b><br><br><a href='index.php' class='link2'>Please Login Now</a><br>
</td>
</tr><tr><td> </td></tr></table></td>
<td width='16' rowspan='2' align='right' valign='top' background='images/right.gif'><img src='images/spacer.gif' width='1' height='1'><img src='images/right.gif' width='16' height='14'></td>
</tr><tr><td valign='top'><img src='images/spacer.gif' width='746' height='10'></td>
</tr><tr><td background='images/footerbg.gif'><img src='images/footerleft.gif' width='16' height='43'></td>
<td background='images/footerbg.gif'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td height='10' colspan='2' align='left'><img src='images/spacer.gif' width='12' height='10'></td>
</tr><tr><td width='746' align='center' valign='top' class='footer'>Copyright © 2007 www.jobhirings.com. All Rights Reserved</td>
</tr></table></td><td background='images/footerbg.gif'><img src='images/footeright.gif' width='16' height='43'></td>
</tr></table></body></html>";
exit;
}

if($_GET['cmd']=="pro"){

echo"<div><form action='forgotpass.php?cmd=update ' method='POST'>
<b class='text3'>Please provide a new password</b><br><br>
<input type='password' name='password' maxlength='30'>
<br>
<br>
<input type='submit' value='New Password'>
</form></td>
</tr><tr><td> </td></tr></table></td>
<td width='16' rowspan='2' align='right' valign='top' background='images/right.gif'><img src='images/spacer.gif' width='1' height='1'><img src='images/right.gif' width='16' height='14'></td>
</tr><tr><td valign='top'><img src='images/spacer.gif' width='746' height='10'></td>
</tr><tr><td background='images/footerbg.gif'><img src='images/footerleft.gif' width='16' height='43'></td>
<td background='images/footerbg.gif'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td height='10' colspan='2' align='left'><img src='images/spacer.gif' width='12' height='10'></td>
</tr><tr><td width='746' align='center' valign='top' class='footer'>Copyright © 2007 www.jobhirings.com. All Rights Reserved</td>
</tr></table></td><td background='images/footerbg.gif'><img src='images/footeright.gif' width='16' height='43'></td>
</tr></table></body></html>";
exit;
}
}
?>


<form action="forgotpass.php?cmd=pro" method="POST">
<b class="text3">Email Address:</b> <input type="text" name="email" maxlength="30">
 
<input type="submit" value="Get New Password">
</form></td>
        </tr>
        <tr>
          <td> </td>
        </tr>
    </table></td>
    <td width="16" rowspan="2" align="right" valign="top" background="images/right.gif"><img src="images/spacer.gif" width="1" height="1"><img src="images/right.gif" width="16" height="14"></td>
  </tr>
  <tr>
    <td valign="top"><img src="images/spacer.gif" width="746" height="10"></td>
  </tr>
  <tr>
    <td background="images/footerbg.gif"><img src="images/footerleft.gif" width="16" height="43"></td>
    <td background="images/footerbg.gif"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="10" colspan="2" align="left"><img src="images/spacer.gif" width="12" height="10"></td>
      </tr>
      <tr>
        <td width="746" align="center" valign="top" class="footer">Copyright © 2007 www.jobhirings.com. All Rights Reserved</td>
      </tr>
    </table></td>
    <td background="images/footerbg.gif"><img src="images/footeright.gif" width="16" height="43"></td>
  </tr>
</table>
</body>
</html>

 

 

also, considering my current code, is there a way that the form could just create a random password instead of

letting the user input there own new password? i mean for security reasons.

then the new password will just be sent to the user's email.

 

hope you could help me with this.

 

thanks!

Link to comment
Share on other sites

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.