simonp Posted June 12, 2007 Share Posted June 12, 2007 Hello, We have a simple contact form written in PHP that worked fine until our server was upgraded to PHP Version 4.4.6 - now it doesn't send the mail. Is there a way to find out why not? I know you can force errors to the browser in CGI Perl - can I do anything in PHP? Hope someone can help! Simon Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/ Share on other sites More sharing options...
lighton Posted June 12, 2007 Share Posted June 12, 2007 it might help if you post the script Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273008 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 Hi, Sorry - here's the code: <?php // only validate form when form is submitted $sucess = 'no'; if(isset($submit_button)){ $error_msg=''; if($contactName=='') { $error_msg.="<li>Please tell us your name!</li>"; } if($contactEnquiry=='') { $error_msg.="<li>You didn't enter a message!</li>"; } // display error message if any, if not, proceed to other processing if($error_msg==''){ // Everything seems cool so let us do what we do $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); //Delivery info $deliverto='EMAILADDRESS REMOVED'; $subject='customer enquiry'; $mailcontent = "customer enquiry\n\n" .'Name: '.$contactName."\n" .'E-mail: '.$contactEmail."\n" .'Telephone: '.$contactTelephone."\n" .'Domain: '.$contactDomain."\n" .'Ringback: '.$contactRingback."\n" .'Enquiry: '.$contactEnquiry."\n\n" .'IP address: '. $_SERVER["REMOTE_ADDR"]."\n" .'Hostname: ' . $hostname; $from = "From: $contactName <$contactEmail>\r\n"; mail($deliverto, $subject, $mailcontent, $from); ?> Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273019 Share on other sites More sharing options...
lighton Posted June 12, 2007 Share Posted June 12, 2007 can you post the whole thing html en all Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273024 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 Hi, It's this part that's not working - any suggestions? Thanks Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273026 Share on other sites More sharing options...
Yesideez Posted June 12, 2007 Share Posted June 12, 2007 Looking at the code I would say the error is somewhere in the contents of the $mailcontent variable as everything else looks fine. Experiment with sending a very basic email like one piece of text and see what happens. Progressively add more data and see when it fails. I'd also advise to add some sort of basic error checking with the mail() function like this: if (mail($deliverto, $subject, $mailcontent, $from)) { echo 'Mail sent OK'; } else { echo 'Mail sending failed'; } Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273052 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 humm - seems like it might not be the mail code after all - it doesn't look like it's even passing the variables from the form. This is the code on the form. Can anyone see what might be wrong?: <form method="post" name="contactform" action="submission.php" style="margin: 0px; padding: 0px;"> <table border="0" class="contactTable noprint"> <tr> <td colspan="2">Leave your details here and we'll get back to you by e-mail or phone.</td> </tr> <tr> <td> <label for="contactName"><b>Your name:</b></label> </td> <td> <input type="formText" name="contactName" value="<?php echo $contactName; ?>"> </td> </tr> <tr> <td> <label for="contactEmail"><b>Your e-mail address:</b></label> </td> <td> <input type="text" name="contactEmail" value="<?php echo $contactEmail; ?>"> </td> </tr> <tr> <td> <label for="contactTelephone"><b>Your telephone number:</b></label> </td> <td> <input type="text" name="contactTelephone" value="<?php echo $contactTelephone; ?>"> </td> </tr> <tr> <td> <label for="contactDomain"><b>Your domain name</b> (if applicable):</label> </td> <td> <input type="text" name="contactDomain" size="27" value="<?php echo $contactDomain; ?>"> </td> </tr> <tr> <td valign="top"> <label for="contactEnquiry" valign="top"><b>Your enquiry:</b></label> </td> <td> <textarea rows="6" name="contactEnquiry" style="width: 200px;"><?php echo $contactEnquiry; ?></textarea> </td> </tr> <tr> <td valign="top"> <label for="contactRingback" valign="top"><b>I'd like you to call me back:</b></label> </td> <td> <select name="contactRingback"> <option value="No ringback required" selected>I don't require a ringback</option> <option value="Call as soon as possible">As soon as possible</option> <option value="Call sometime today">Sometime today</option> <option value="Call tomorrow">Tomorrow</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Send your enquiry" name="submit_button" id="submit_button"> </td> </tr> </table> </form> . . . .and this is the submission.php <?php // only validate form when form is submitted $sucess = 'no'; if(isset($submit_button)){ $error_msg=''; if($contactName=='') { $error_msg.="<li>Please tell us your name!</li>"; } if($contactEnquiry=='') { $error_msg.="<li>You didn't enter a message!</li>"; } // display error message if any, if not, proceed to other processing if($error_msg==''){ // Everything seems cool so let us do what we do $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); //Delivery info $deliverto='EMAIL ADDRESS REMOVED'; $subject='customer enquiry'; $mailcontent = "customer enquiry\n\n" .'Name: '.$contactName."\n" .'E-mail: '.$contactEmail."\n" .'Telephone: '.$contactTelephone."\n" .'Domain: '.$contactDomain."\n" .'Ringback: '.$contactRingback."\n" .'Enquiry: '.$contactEnquiry."\n\n" .'IP address: '. $_SERVER["REMOTE_ADDR"]."\n" .'Hostname: ' . $hostname; $from = "From: $contactName <$contactEmail>\r\n"; mail($deliverto, $subject, $mailcontent, $from); //if (mail($deliverto, $subject, $mailcontent, $from)) { // echo 'Mail sent OK'; //} else { // echo 'Mail sending failed'; //} ?> <p>Thanks for your enquiry. We'll get back to you as soon as possible.</p> <?php echo "<table class=\"contactConfirm\" border=\"0\">"; echo "<tr><td colspan=\"2\" class=\"contactConfirmX\"> here's what you submitted:</td></tr>"; if ($contactName !== '') { echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">Name:</td><td valign=\"top\">$contactName</td> </tr>"; } if ($contactEmail !== '') { echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">E-mail:</td><td valign=\"top\">$contactEmail</td> </tr> "; } if ($contactTelephone !== '') { echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">Telephone:</td><td valign=\"top\">$contactTelephone</td> </tr>"; } if ($contactDomain !== '') { echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">Domain:</td><td valign=\"top\">$contactDomain</td> </tr>"; } echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">Ringback:</td><td valign=\"top\">$contactRingback</td> </tr>"; if ($contactEnquiry !== '') { echo " <tr> <td valign=\"top\" class=\"contactConfirmY\">Enquiry:</td><td valign=\"top\">$contactEnquiry</td> </tr> "; } echo "</table>"; echo "</tr></td>"; $sucess = 'yes'; } else { echo "<tr><td colspan=\"2\">"; echo "<p>Sorry, there was an error with your submission. Take a look at the problems listed below and try again.</p>"; echo "<ul class=\"formError\">$error_msg</ul>"; echo "</tr></td>"; } } ?> <?php if($sucess=='no'){ ?> <?php echo $sucess; ?> <div class="contactTitle"><img src="contactform.gif" alt="Contact form" border="0"></div> <form method="post" name="contactform" action="submission.php" style="margin: 0px; padding: 0px;"> <table border="0" class="contactTable"> <tr> <td colspan="2">Leave your details here and we'll get back to you by e-mail or phone.</td> </tr> <tr> <td> <label for="contactName"><b>Your name:</b></label> </td> <td> <input type="formText" name="contactName" value="<?php echo $contactName; ?>"> </td> </tr> <tr> <td> <label for="contactEmail"><b>Your e-mail address:</b></label> </td> <td> <input type="text" name="contactEmail" value="<?php echo $contactEmail; ?>"> </td> </tr> <tr> <td> <label for="contactTelephone"><b>Your telephone number:</b></label> </td> <td> <input type="text" name="contactTelephone" value="<?php echo $contactTelephone; ?>"> </td> </tr> <tr> <td> <label for="contactDomain"><b>Your domain name</b> (if applicable):</label> </td> <td> <input type="text" name="contactDomain" size="27" value="<?php echo $contactDomain; ?>"> </td> </tr> <tr> <td valign="top"> <label for="contactEnquiry" valign="top"><b>Your enquiry:</b></label> </td> <td> <textarea rows="6" name="contactEnquiry" cols="20"><?php echo $contactEnquiry; ?></textarea> </td> </tr> <tr> <td valign="top"> <label for="contactRingback" valign="top"><b>I'd like you to call me back:</b></label> </td> <td> <select name="contactRingback"> <option value="No ringback required" selected>I don't require a ringback</option> <option value="Call as soon as possible">As soon as possible</option> <option value="Call sometime today">Sometime today</option> <option value="Call tomorrow">Tomorrow</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Send your enquiry" name="submit_button" id="submit_button"> </td> </tr> </table> </form> <?php }; ?> Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273075 Share on other sites More sharing options...
Yesideez Posted June 12, 2007 Share Posted June 12, 2007 This looks scary: [code=php:0]if(isset($submit_button)){ Try this: if ($_POST['submit_button']) { Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273080 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 I've actually remed all that out which is how I found out nothing is being passed from the form //if(isset($submit_button)){ // $error_msg=''; // if($contactName=='') { // $error_msg.="<li>Please tell us your name!</li>"; // } // // // if($contactEnquiry=='') { // $error_msg.="<li>You didn't enter a message!</li>"; // } // display error message if any, if not, proceed to other processing // if($error_msg==''){ Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273081 Share on other sites More sharing options...
Yesideez Posted June 12, 2007 Share Posted June 12, 2007 if(isset($submit_button)){ What is the contents of $submit_button? It also doesn't look like you're pulling the data from the form - Are you using $_POST anywhere? Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273083 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 You're script was written with the assumption that register_globals is enabled. That used to be the case, but has not been the default for at least 2 or 3 years. You now have to retrieve all values that are returned from a form via either the $_GET or $_POST super global arrays. Ken Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273130 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 Ah! Thanks kenrbnsn - that would make sense. I think for now I'll enable register_globals for that account and investigate a fix at a later date. Simon Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273133 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 Please don't enable register_globals -- it can lead to security problems. Take the time to fix the problems now, you will thank yourself later. Ken Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273134 Share on other sites More sharing options...
simonp Posted June 12, 2007 Author Share Posted June 12, 2007 ooops - we've done that for quite a few sites running oscommerce. Will start looking at corrections ASAP. Thanks Simon Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273135 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 I just read about a fix to oscommerce that lets it run with register_globals disabled. I will try to find it again and post the link. Ken Link to comment https://forums.phpfreaks.com/topic/55230-php-upgrade-problem-script-no-longer-works/#findComment-273138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.