Jump to content

why is the code below not working...header problem ?


jd2007

Recommended Posts

this is a system for users to retrieve their password/username...

 

<div class=forget>
<h3>Forgot Your Username ?</h3>
<form method="post" action="retrieve.php">
E-mail: <input type=text name=remailu />  <input type=submit value=Retrieve />
</form>
<h3>Forget Your Password ?</h3>
<form method="post" action="retrieve.php">
E-mail: <input type=text name=remailp />   <input type=submit value=Retrieve />
</form>
<h3>Forget Your Username and Password ?</h3>
<form method="post" action="retrieve.php">
E-mail: <input type=text name=remailup />  <input type=submit value=Retrieve />
</form>
</div>

 

retrieve.php

 

<?php
if ($_POST["remailu"])
{
include("connect.php");
$query="SELECT username FROM users WHERE email='$_POST[remailu]'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
if (!$row)
{
  $notfound="No user with such e-mail on this database.";
  header("location:forgot.php?notfound=$notfound");
}
else
{
  $to=$_POST[remailu];
  $subject="Username Retrieval";
  $message="Your username is $row[0].";
  $mail=mail($to, $subject, $message);
  if ($mail)
  {
   $sent="Your username was sent to your e-mail address";
   header("location:forgot.php?sent=$sent");
  }
  else
  {
   $error="There was a problem. Please try again later.";
   header("location:forgot.php?error=$error");
  }
}
}
else if ($_POST["remailp"])
{
include("connect.php");
$query="SELECT password FROM users WHERE email='$_POST[remailp]'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
if (!$row)
{
  $notfound="No user with such e-mail on this database.";
  header("location:forgot.php?notfound=$notfound");
}
else
{
  $to=$_POST["remailp"];
  $subject="Password Retrieval";
  $message="Your username is $row[0].";
  $mail=mail($to,$subject,$message);
  if ($mail)
  {
   $s="Your password was sent to your e-mail address";
   header("location:forgot.php?sent='$s'");
  }
  else
  {
   $error="There was a problem. Please try again later.";
   header("location:forgot.php?error='$error'");
  }
}
}
else
{
include("connect.php");
$query="SELECT username, password FROM users WHERE email='$_POST[remailup]'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
if (!$row)
{
  $notfound="No user with such e-mail on this database.";
  header("location:forgot.php?notfound=$notfound");
}
else
{
  $to=$_POST[remailup];
  $subject="Username and Password Retrieval";
  $message="Your username is $row[0] and $row[1].";
  $mail=mail($to, $subject, $message);
  if ($mail)
  {
   $sent="Your username and password was sent to your e-mail address";
   header("location:forgot.php?sent=$sent");
  }
  else
  {
   $error="There was a problem. Please try again later.";
   header("location:forgot.php?error=$error");
  }
}
}
?>

 

the output is :

 

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\AppServ\www\Freelance Project 1\retrieve.php on line 47

 

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Freelance Project 1\retrieve.php:47) in C:\AppServ\www\Freelance Project 1\retrieve.php on line 56

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.