By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,567 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,567 IT Pros & Developers. It's quick & easy.

Need help for forgot password page

P: 52
Hi all, i need help in this forgot password page, as the error message is show in another page cause the arrangement of the design in a mess. As i want to show the error message on the forgot password page.


[PHP]
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();  // Start Session
  3. session_register("session");
  4.  
  5. $email_address = $_POST['email_address'];
  6. if (!isset($_POST['email_address'])) {
  7. ?>
  8. <title>QUALTY MANAGEMENT SYSTEM</title>
  9. <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  10. <!-- fwtable fwsrc="layout.png" fwbase="layout.gif" fwstyle="Dreamweaver" fwdocid = "1867439519" fwnested="0" -->
  11.   <tr>
  12.    <td><img src="images/spacer.gif" width="100" height="1" border="0" alt=""></td>
  13.    <td><img src="images/spacer.gif" width="89" height="1" border="0" alt=""></td>
  14.    <td><img src="images/spacer.gif" width="113" height="1" border="0" alt=""></td>
  15.    <td><img src="images/spacer.gif" width="124" height="1" border="0" alt=""></td>
  16.    <td><img src="images/spacer.gif" width="74" height="1" border="0" alt=""></td>
  17.    <td><img src="images/spacer.gif" width="51" height="1" border="0" alt=""></td>
  18.    <td><img src="images/spacer.gif" width="49" height="1" border="0" alt=""></td>
  19.    <td><img src="images/spacer.gif" width="100" height="1" border="0" alt=""></td>
  20.    <td><img src="images/spacer.gif" width="100" height="1" border="0" alt=""></td>
  21.    <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  22.   </tr>
  23.  
  24.   <tr>
  25.    <td colspan="2"><a href="main.php"><img name="layout_r1_c1" src="images/layout_r1_c1.gif" width="189" height="80" border="0" alt=""></a></td>
  26.    <td colspan="7"><img name="layout_r1_c3" src="images/layout_r1_c3.gif" width="611" height="80" border="0" alt=""></td>
  27.    <td><img src="images/spacer.gif" width="1" height="80" border="0" alt=""></td>
  28.   </tr>
  29.   <tr>
  30.    <td colspan="9">&nbsp;</td>
  31.    <td><img src="images/spacer.gif" width="1" height="8" border="0" alt=""></td>
  32.   </tr>
  33.   <tr>
  34.     <td colspan="4">
  35.       <span class="login_name"> </span></td>
  36.    <td colspan="3"><img name="layout_r3_c5" src="images/layout_r3_c5.gif" width="174" height="50" border="0" alt=""></td>
  37.   <td rowspan="2" colspan="2"><img name="layout_r3_c8" src="images/layout_r3_c8.gif" width="200" height="70" border="0" alt=""></td>
  38.    <td><img src="images/spacer.gif" width="1" height="50" border="0" alt=""></td>
  39.   </tr>
  40.   <tr>
  41.    <td rowspan="5"><img name="layout_r4_c1" src="images/info.gif" width="84" height="81" border="0" alt=""></td>
  42.    <td rowspan="5" colspan="2"><img name="layout_r4_c2" src="images/layout_r4_c2.gif" width="202" height="90" border="0" alt=""></td>
  43.    <td rowspan="7"><img name="layout_r4_c4" src="images/layout_r4_c4.gif" width="124" height="160" border="0" alt=""></td>
  44.    <td rowspan="3"><img name="layout_r4_c5" src="images/layout_r4_c5.gif" width="74" height="60" border="0" alt=""></td>
  45.    <td colspan="2"><img name="layout_r4_c6" src="images/layout_r4_c6.gif" width="100" height="20" border="0" alt=""></td>
  46.    <td><img src="images/spacer.gif" width="1" height="20" border="0" alt=""></td>
  47.   </tr>
  48.   <tr>
  49.    <td rowspan="4" colspan="2"><img name="layout_r5_c6" src="images/layout_r5_c6.gif" width="100" height="70" border="0" alt=""></td>
  50.    <td><img name="layout_r5_c8" src="images/layout_r5_c8.gif" width="100" height="20" border="0" alt=""></td>
  51.    <td><img name="layout_r5_c9" src="images/layout_r5_c9.gif" width="100" height="20" border="0" alt=""></td>
  52.    <td><img src="images/spacer.gif" width="1" height="20" border="0" alt=""></td>
  53.   </tr>
  54.   <tr>
  55.    <td rowspan="3"><img name="layout_r6_c8" src="images/layout_r6_c8.gif" width="100" height="50" border="0" alt=""></td>
  56.    <td rowspan="3"><img name="layout_r6_c9" src="images/layout_r6_c9.gif" width="100" height="50" border="0" alt=""></td>
  57.    <td><img src="images/spacer.gif" width="1" height="20" border="0" alt=""></td>
  58.   </tr>
  59.   <tr>
  60.    <td><img name="layout_r7_c5" src="images/layout_r7_c5.gif" width="74" height="20" border="0" alt=""></td>
  61.    <td><img src="images/spacer.gif" width="1" height="20" border="0" alt=""></td>
  62.   </tr>
  63.   <tr>
  64.    <td rowspan="3"><img name="layout_r8_c5" src="images/layout_r8_c5.gif" width="74" height="80" border="0" alt=""></td>
  65.    <td><img src="images/spacer.gif" width="1" height="10" border="0" alt=""></td>
  66.   </tr>
  67.   <tr>
  68.     <td colspan="2" rowspan="4" valign="top">
  69.       <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
  70.  
  71.       <p class="style3">
  72.         <label for="email_address">Email:</label>
  73.         <input type="text" title="Please enter your email address" name="email_address" size="20"/>
  74.       </p>
  75.       <p class="style3">
  76.         <label title="Reset Password"></label>
  77.         <input name="submit" type="submit" class="submit-button" value="Submit"/>
  78.       </p>
  79.     </form>
  80.         <?php
  81. }
  82. elseif (empty($email_address)) {
  83.     echo $empty_fields_message;
  84. }
  85. else {
  86. $email_address=mysql_real_escape_string($email_address);
  87. $status = "OK";
  88. $msg="";
  89. //error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
  90. if (!stristr($email_address,"@") OR !stristr($email_address,".")) {
  91. $msg="Your email address is not correct<BR>"; 
  92. $status= "NOTOK";}
  93.  
  94. echo "<br><br>";
  95. if($status=="OK"){  
  96. $query="SELECT email_address,username FROM users WHERE users.email_address = '$email_address'";
  97. $st=mysql_query($query);
  98. $recs=mysql_num_rows($st);
  99. $row=mysql_fetch_object($st);
  100. $em=$row->email_address;// email is stored to a variable
  101.  if ($recs == 0) {  echo "<center><font face='Verdana' size='2' color=red><b>No Password</b><br> Sorry Your address is not there in our database.</center>"; exit;}
  102. function makeRandomPassword() { 
  103.           $salt = "abchefghjkmnpqrstuvwxyz0123456789"; 
  104.           srand((double)microtime()*1000000);  
  105.           $i = 0; 
  106.           while ($i <= 7) { 
  107.                 $num = rand() % 33; 
  108.                 $tmp = substr($salt, $num, 1); 
  109.                 $pass = $pass . $tmp; 
  110.                 $i++; 
  111.           } 
  112.           return $pass; 
  113.     } 
  114.     $random_password = makeRandomPassword(); 
  115.     $db_password = md5($random_password); 
  116.  
  117.     $sql = mysql_query("UPDATE users SET password='$db_password'  
  118.                 WHERE email_address='$email_address'"); 
  119.  
  120.     $subject = "Your password at www.yoursite.com"; 
  121.     $message = "Hi, we have reset your password. 
  122.  
  123.     New Password: $random_password 
  124.  
  125.     Once logged in you can change your password 
  126.  
  127.     Thanks! 
  128.     Site admin 
  129.  
  130.     This is an automated response, please do not reply!"; 
  131.  
  132.     mail($email_address, $subject, $message, "From: <admin@site.com>\n 
  133.         X-Mailer: PHP/" . phpversion()); 
  134.     echo "Your password has been sent! Please check your email!<br />"; 
  135.  } 
  136.  else  {"<middle><font face='Verdana' size='2' color=red >$msg <br><br><input type='button' value='Retry' onClick='history.go(-1)'></middle></font>";}
  137. }
  138. ?>
  139.       <br>
  140.       <br></td>
  141.     <td rowspan="2">&nbsp;</td>
  142.    <td colspan="2"><img name="layout_r9_c6" src="images/layout_r9_c6.gif" width="100" height="20" border="0" alt=""></td>
  143.    <td rowspan="2"><img name="layout_r9_c8" src="images/layout_r9_c8.gif" width="100" height="70" border="0" alt=""></td>
  144.    <td rowspan="2"><img name="layout_r9_c9" src="images/layout_r9_c9.gif" width="100" height="70" border="0" alt=""></td>
  145.    <td><img src="images/spacer.gif" width="1" height="20" border="0" alt=""></td>
  146.   </tr>
  147.   <tr>
  148.    <td colspan="2"><img name="layout_r10_c6" src="images/layout_r10_c6.gif" width="100" height="50" border="0" alt=""></td>
  149.    <td><img src="images/spacer.gif" width="1" height="50" border="0" alt=""></td>
  150.   </tr>
  151.   <tr>
  152.    <td rowspan="2"><img name="layout_r11_c3" src="images/layout_r11_c3.gif" width="113" height="272" border="0" alt=""></td>
  153.    <td colspan="3"><p class="style1">&nbsp;</p>    </td>
  154.    <td colspan="3">&nbsp;</td>
  155.    <td><img src="images/spacer.gif" width="1" height="136" border="0" alt=""></td>
  156.   </tr>
  157.   <tr>
  158.    <td colspan="3"><img name="layout_r12_c4" src="images/layout_r12_c4.gif" width="249" height="136" border="0" alt=""></td>
  159.    <td colspan="3"><img name="layout_r12_c7" src="images/layout_r12_c7.gif" width="249" height="136" border="0" alt=""></td>
  160.    <td><img src="images/spacer.gif" width="1" height="136" border="0" alt=""></td>
  161.   </tr>
  162.   <tr>
  163.    <td colspan="9"><img name="layout_r13_c1" src="images/layout_r13_c1.gif" width="800" height="30" border="0" alt=""></td>
  164.    <td><img src="images/spacer.gif" width="1" height="30" border="0" alt=""></td>
  165.   </tr>
  166. </table>
  167.  
[/PHP]
Jul 11 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Heya, chaos.

What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 11 '07 #2

P: 52
Heya, chaos.

What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.

My echo message tend to show out on other page instead of appearing at the forgot password page.
What can i do in order to show the echo message in hidden message??
Example : echo "Your password has been sent! Please check your email!
$msg="Your email address is not correct
Jul 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.