mariocesar Posted January 31, 2007 Share Posted January 31, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36546-e-mail-script-dont-work/ Share on other sites More sharing options...
HuggieBear Posted February 1, 2007 Share Posted February 1, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/36546-e-mail-script-dont-work/#findComment-174116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.