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

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.