Shamrox Posted May 30, 2007 Share Posted May 30, 2007 Can anyone tell me what is wrong here? First it failed to send the email, now it fails to load anything on the page. This is driving me nuts. <?PHP if(@$_REQUEST['step'] != "two") { ob_start(); include("invoice.php"); $to = $invoice['billemail']; //change this ob_end_clean(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Send <?PHP echo $_REQUEST['form']; ?></title> </head> <body> <form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="invoicenumber" value="<?PHP echo $_REQUEST['invoicenumber']; ?>"> <input type="hidden" name="form" value="<?PHP echo $_REQUEST['form']; ?>"> <input type="hidden" name="step" value="two"> <p> Send <?PHP echo $_REQUEST['form']; ?> to: <input type="text" name="send_to" value="<?PHP echo $to; ?>" size="50"> (Example: email@yourdomain.com, email2@yourdomain.com)<br> <input type="submit" name="submit_button" value="Send <?PHP echo $_REQUEST['form']; ?>"> </p> </form> </body> </html> <?PHP exit(); } elseif(@$_REQUEST['step'] == "two") { ob_start(); include("invoice.php"); $message = ob_get_contents(); //ob_end_clean(); $success = "Invoice sent successfully."; $failure = "Failed to send invoice email!!"; $from = $invoice['stb_email']; $subject = "Invoice - " . $invoice['invoicenumber'] . " - " . $invoice['studentlast'] . " - " . $invoice['coursecode'] . " - " . $invoice['coursename'] . ""; else { $send_to = $_POST['send_to']; $message = str_replace("../invoice.css", "http://www.domain.com/invoice.css", $message); $message = preg_replace("/\.?\.?\/images\/logo_hi-res_sm.gif/", "http://www.domain.com/images/logo_hi-res_sm.gif", $message); $message = str_replace("/images/gray_dot.gif", "http://www.domain.com/images/gray_dot.gif", $message); $message = str_replace("/images/shared_dot_clear.gif", "http://www.domain.com/images/shared_dot_clear.gif", $message); $sep = "\n"; $boundary = md5(uniqid("",true)); $b1 = "b1---$boundary"; $headers = "From: $from$sep"; //$headers .= "To: $send_to$sep"; $headers .= "Return-Path: $from$sep"; $headers .= "MIME-Version: 1.0$sep"; $headers .= "Content-Type: multipart/alternative; boundary=\"$b1\"$sep"; $headers .= "$sep"; //now set up the message $messageHeader = "--$b1$sep"; //default message $defaultmessage = "Your email client cannot read html email"; $messageHeader .= $defaultmessage.$sep; $messageHeader .= "$sep"; //html message $messageHeader .= "--$b1$sep"; $messageHeader .= 'Content-Type: text/html; charset="iso-8859-1"'.$sep; $messageHeader .= "Content-Transfer-Encoding: 8bit$sep"; $messageHeader .= "$sep"; $messageHeader .= $message; $messageHeader .= "$sep"; $messageHeader .= "--$b1--"; $messageHeader .= "$sep"; echo "<pre>$headers \r\n $messageHeader</pre>"; $results = @mail($send_to, $subject, $messageHeader, $headers); } if($results) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Message Sent</title> </head> <body> <p><a href="dashboard-new.php">Dashboard</a> | <a href="registrar_new.php?registrarid=<?PHP echo $_REQUEST['registrarid']; ?>">Registrar</a></p> <p><?PHP echo $success; ?></p> <p>Message sent to: <?PHP echo $send_to; ?></p> <p>The following message was sent:</p> <hr> <?PHP echo $message; ?> </body> </html> <?PHP } else { echo $failure; } exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53614-curly-brace-bad-code-help/ Share on other sites More sharing options...
wildteen88 Posted May 30, 2007 Share Posted May 30, 2007 You have an empty else on line 41: 40. $subject = "Invoice - " . $invoice['invoicenumber'] . " - " . $invoice['studentlast'] . " - " . $invoice['coursecode'] . " - " . $invoice['coursename'] . ""; 41. else 42. { 43. $send_to = $_POST['send_to']; Quote Link to comment https://forums.phpfreaks.com/topic/53614-curly-brace-bad-code-help/#findComment-265011 Share on other sites More sharing options...
Shamrox Posted June 1, 2007 Author Share Posted June 1, 2007 here is my latest code. The form loads now but blank and nevers shows up in the email even though it says it was successful. Is there a way to find out why the form data is not loading in the form now? <?php if(@$_REQUEST['step'] != "two") { ob_start(); include("invoice.php"); $to = $invoice['billemail']; //change this ob_end_clean(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Send <?PHP echo $_REQUEST['form']; ?></title> </head> <body> <form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="invoicenumber" value="<?PHP echo $_REQUEST['invoicenumber']; ?>"> <input type="hidden" name="form" value="<?PHP echo $_REQUEST['form']; ?>"> <input type="hidden" name="step" value="two"> <p> Send <?PHP echo $_REQUEST['form']; ?> to: <input type="text" name="send_to" value="<?PHP echo $to; ?>" size="50"> (Example: email@yourdomain.com, email2@yourdomain.com)<br> <input type="submit" name="submit_button" value="Send <?PHP echo $_REQUEST['form']; ?>"> </p> </form> </body> </html> <?PHP exit(); }elseif(@$_REQUEST['step'] == "two"){ ob_start(); if($_REQUEST['form'] == "invoice"){ include("invoice.php"); } $message = ob_get_contents(); ob_end_clean(); $success = "Invoice sent successfully."; $failure = "Failed to send invoice email!!"; if($_REQUEST['form'] == "invoice"){ $success = "Invoice sent successfully."; $failure = "Failed to send invoice email."; $from = $invoice['stb_email']; $subject = "Invoice - " . $invoice['invoicenumber'] . " - " . $invoice['studentlast'] . " - " . $invoice['coursecode'] . " - " . $invoice['coursename'] . ""; //}else { $send_to = $_POST['send_to']; $message = str_replace("../invoice.css", "http://www.domain.com/invoice.css", $message); $message = preg_replace("/\.?\.?\/images\/logo_hi-res_sm.gif/", "http://www.domain.com/images/logo_hi-res_sm.gif", $message); $message = str_replace("/images/gray_dot.gif", "http://www.domain.com/images/gray_dot.gif", $message); $message = str_replace("/images/shared_dot_clear.gif", "http://www.domain.com/images/shared_dot_clear.gif", $message); $sep = "\n"; $boundary = md5(uniqid("",true)); $b1 = "b1---$boundary"; $headers = "From: $from$sep"; $headers .= "Return-Path: $from$sep"; $headers .= "MIME-Version: 1.0$sep"; $headers .= "Content-Type: multipart/alternative; boundary=\"$b1\"$sep"; $headers .= "$sep"; //now set up the message $messageHeader = "--$b1$sep"; //default message $defaultmessage = "Your email client cannot read html email"; $messageHeader .= $defaultmessage.$sep; $messageHeader .= "$sep"; //html message $messageHeader .= "--$b1$sep"; $messageHeader .= 'Content-Type: text/html; charset="iso-8859-1"'.$sep; $messageHeader .= "Content-Transfer-Encoding: 8bit$sep"; $messageHeader .= "$sep"; $messageHeader .= $message; $messageHeader .= "$sep"; $messageHeader .= "--$b1--"; $messageHeader .= "$sep"; echo "<pre>$headers \r\n $messageHeader</pre>"; $results = @mail($send_to, $subject, $messageHeader, $headers); }if($results){ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Message Sent</title> </head> <body> <p><a href="dashboard-new.php">Dashboard</a> | <a href="registrar_new.php?registrarid=<?PHP echo $_REQUEST['registrarid']; ?>">Registrar</a></p> <p><?PHP echo $success; ?></p> <p>Message sent to: <?PHP echo $send_to; ?></p> <p>The following message was sent:</p> <hr> <?PHP echo $message; ?> </body> </html> <?PHP }else { echo $failure; } exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53614-curly-brace-bad-code-help/#findComment-266330 Share on other sites More sharing options...
per1os Posted June 1, 2007 Share Posted June 1, 2007 The mail function is very touchy and different it will return false when a mail is sent and return true when no mail is sent. The $sep should be \r\n You may try using the "-f" parameter www.php.net/mail (look at the mail function) for sending an email. Also know that most emails such as yahoo, hotmail, aol etc filter our mail coming from servers as junk mail. Anyhow hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/53614-curly-brace-bad-code-help/#findComment-266332 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.