Click to See Complete Forum and Search --> : header problem


kproc
02-17-2007, 08:38 PM
Hi the below code is give me an error

Warning: Header may not contain more than a single header, new line detected. in /mnt/w0400/d11/s01/b02a5c57/www/etreasures.ca/Scripts/codeEmailMembers.php on line 29

I cannot figure out where the second header is being send from

any help is excellent


<?php
include ("../Connections/db.php");

$subject = $_POST['subject'];
$message = $_POST['message'];

$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email_address FROM members");

$email_count=mysql_num_rows($emails);

while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email_address"];
mail($email, $subject,
$message, "From:eTreasures.ca <webmaster@etreasures.ca>");

$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;

} // end of while loop
}

$msg .= "<script language=\"JavaScript\">\n";
$msg .= "alert('$email_count email(s) have been sent');\n";
$msg .= "</script>";
header ("location: ../admin/emailMembers.php?msg=$msg");
?>

kproc
02-17-2007, 08:58 PM
I figured out the header problem, its not sending to all the people in the database.
it sent to the first 50.

<?php
include ("../Connections/db.php");

$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['message']);

$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email_address FROM solicitation WHERE date_emailed != '2007-02-17'")or die (mysql_error());

$email_count=mysql_num_rows($emails);
$dateMailed = date("Y-m-d");
while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email_address"];

mysql_query("UPDATE solicitation SET date_emailed = '$dateMailed' WHERE email_address = '$email'")or die (mysql_error());

mail($email, $subject,
$message, "From:eTreasures.ca <webmaster@etreasures.ca>");

$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;


} // end of while loop
}
?>
<?php
$msg = "<script language=\"JavaScript\">\n";
$msg .= "alert('$email_count email(s) have been sent');\n";
$msg .= "</script>";
$msg .= "Emails Sent";
$msg = urlencode($msg);
header("location: ../admin/solicitationEmailer.php?msg=$msg");
?>

kproc
02-17-2007, 09:22 PM
as it goes through the loop it pop asking to down load the form.. Not shure why this is happening

kproc
02-18-2007, 07:48 AM
I'm having a problem with headers on this page, it works great until the last section

thank you
Warning: Header may not contain more than a single header, new line detected. in /mnt/w0400/d11/s01/b02a5c57/www/etreasures.ca/Scripts/CodeChangePassword.php on line 52

<?php session_start();
include ("../Connections/db.php");

if(isset($submit_password)){
$user_id = $_SESSION['user_id'];
$email_address =$_SESSION['email_address'];

$new_password = $_POST['new_password'];
$confirm_password = $_POST['confirm_password'];

if($new_password != $confirm_password){

$msg .= 'Passwords do not match.<br />';

urlencode($msg);
header("Location: ../portal/editprofile.php?msg=$msg");
exit();
}

if(($new_password =="")) {

$msg .= 'Enter Password.<br />';


urlencode($msg);
header("Location: ../portal/editprofile.php?msg=$msg");
exit();
}
$db_password = md5($new_password);

$sql = mysql_query("UPDATE members SET password='$db_password' WHERE user_id='$user_id'");

$subject = "You changed your password at Etreasures!";
$message = "Save this email as it contains the password that you selected.
Not to worry your password has been encrypted to protect your privacy

New Password: $new_password

http://www.etreasures.ca

Thanks!
etreasures.ca

This is an automated response, please do not reply!";

mail($email_address, $subject, $message, "From: Etreasures.ca<admin@Etreasures.ca>");


$msg = "Your Password has been changed. You will receive an email
with your new password!";
urlencode($msg);
header("Location: ../portal/editprofile.php?msg=$msg");
}
?>

NightShift58
02-18-2007, 08:23 AM
Change: $msg = "Your Password has been changed. You will receive an email
with your new password!";
urlencode($msg);
header("Location: ../portal/editprofile.php?msg=$msg"); to this:
$msg = "Your Password has been changed. You will receive an email with your new password!";
// the above on 1 (one) line, no line breaks...
urlencode($msg);
header("Location: ../portal/editprofile.php?msg=$msg");

bokeh
02-18-2007, 08:40 AM
And by the way, according to RFC2616 the argument to Location should be absolute.

kproc
02-18-2007, 08:42 AM
thanks that fixed the problem

I'm not sure what you mean by this
according to RFC2616 the argument to Location should be absolute.

bokeh
02-18-2007, 08:59 AM
I'm not sure what you mean by thisRFC2616 (http://www.faqs.org/rfcs/rfc2616)

14.30 Location
The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. [...] For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI.

Location = "Location" ":" absoluteURI

kproc
02-18-2007, 10:29 AM
I picked up a bad habit some where, should I be going through all my pages and fixing this

bokeh
02-18-2007, 10:48 AM
I picked up a bad habit some where, should I be going through all my pages and fixing thisWell none of the majority browsers I have tried stumble on this but it is incorrect.

kproc
02-18-2007, 10:53 AM
As I work thought my pages I will fix it thanks for the information