Jump to content

Recommended Posts

Hello this sis the message I receive :

Warning: mail(): Bad parameters to mail() function, mail not sent. in /home/content/C/o/p/Copymail/html/password.php on line 36

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/C/o/p/Copymail/html/password.php:36) in /home/content/C/o/p/Copymail/html/password.php on line 41

 

this is the code:

 

<?
include("fns.php");
include "config.php";
if(isset($_POST['Submit'])){
//1. Check if form fields are filled in
if(!filledin($_POST)){
header( "Location:Messages.php?msg=7" ); 
exit();
}
$name=$_POST['name'];
$em=$_POST['mail'];

//2. Check if entered name exist

$query="Select pw from user where uname='$name'" or die(mysql_error());
$result= mysql_query($query); 

if(mysql_num_rows($result)>0){
for ($i=0; $i<mysql_num_rows($result); $i++) {
$row = mysql_fetch_assoc($result);

$pass=$row['pw'];
$to="$em\r\n";
$from="From: Admin@jacquesnoah.co.uk\r\n";
$msg="Password:$pass\r\n";
$msg .="Username:$name\r\n";
$msg .="Please change your password as soon as you logon\r\n";
$subject="From Admin re:Your Login Password\r\n";
}
}else{
header( "Location:Messages.php?msg=8" ); 
exit();
}

//4. Send password to user
if(mail($to,$subject,$msg,$from)){
header( "Location:Messages.php?msg=9&email=<?php echo $em; ?>" ); 
exit();
//echo "Please click here to log";
}else{
header( "Location:Messages.php?msg=10"); 
exit();
}
}

?>

 

this is lne 36 :

if(mail($to,$subject,$msg,$from)){

 

this is 41:

header( "Location:Messages.php?msg=10");

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/36546-e-mail-script-dont-work/
Share on other sites

Try this... You don't need all the \r\n on the end of every parameter passed to mail(), only the additional headers.

 

<?php
include("fns.php");
include "config.php";

if(isset($_POST['Submit'])){
   //1. Check if form fields are filled in
   if(!filledin($_POST)){
      header( "Location:Messages.php?msg=7" ); 
      exit();
   }
   $name=$_POST['name'];
   $em=$_POST['mail'];

   //2. Check if entered name exist

   $query="Select pw from user where uname='$name'" or die(mysql_error());
   $result= mysql_query($query);

   if(mysql_num_rows($result)>0){
      for ($i=0; $i<mysql_num_rows($result); $i++) {
         $row = mysql_fetch_assoc($result);
         $pass = $row['pw'];

         $to = $em;
         $from = "From: Admin@jacquesnoah.co.uk\r\n";
         $msg = "Password: $pass";
         $msg .= "Username: $name";
         $msg .= "Please change your password as soon as you logon";
         $subject = "From Admin re: Your Login Password";
      }
   }else{
      header( "Location:Messages.php?msg=8" ); 
      exit();
   }

   //4. Send password to user
   if(mail($to,$subject,$msg,$from)){
      header( "Location: Messages.php?msg=9&email=$em" ); 
      exit();
      //echo "Please click here to log";
   }
   else{
      header( "Location:Messages.php?msg=10"); 
      exit();
   }
}
?>

 

Regards

Huggie

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.