insomnia Posted July 8, 2009 Share Posted July 8, 2009 So, I'm making what should be a simple form, and at 3:45am, I'm stuck. When I hit submit on the front end, it goes to the contact.php file and displays it as a blank page. Funny thing is that after a whole bunch of fiddling, I got it right on one of its incarnations, but it got caught in my spam filter, which I didn't discover until I made a whole load of changes, breaking it again. Any help, or belittling me and then pointing me in the right direction would be greatly appreciated. <?php $EmailTo = 'me@gmail.com'; $Subject = 'Customer Questionnaire'; $EmailFrom = 'response@clients.net' $likelytorefer = Trim(stripslashes($_POST['likelytorefer'])); $continuebusiness = Trim(stripslashes($_POST['continuebusiness'])); $satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs'])); $satisfiedservice = Trim(stripslashes($_POST['satisfiedservice'])); $satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse'])); $satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration'])); $ease = Trim(stripslashes($_POST['ease'])); $website = Trim(stripslashes($_POST['website'])); $knowledge = Trim(stripslashes($_POST['knowledge'])); $recommendation = Trim(stripslashes($_POST['recommendation'])); $cost = Trim(stripslashes($_POST['cost'])); $service = Trim(stripslashes($_POST['service'])); $improve = Trim(stripslashes($_POST['improve'])); $reason = Trim(stripslashes($_POST['reason'])); $Body = ""; $Body .= "How likely the respondent is to recommend Company: "; $Body .= $likelytorefer; $Body .= "\n"; $Body .= "How likely the respondent is to continue business with Company:"; $Body .= $continuebusiness; $Body .= "\n"; $Body .= "How satisfied the respondent is with repairs: "; $Body .= $satisfiedrepairs; $Body .= "\n"; $Body .= "How satisfied the respondent is with service: "; $Body .= $satisfiedservice; $Body .= "\n"; $Body .= "How satisfied the respondent is with response times: "; $Body .= $satisfiedresponse; $Body .= "\n"; $Body .= "How satisfied the respondent is with administration service: "; $Body .= $satisfiedadministration; $Body .= "\n"; $Body .= "Ease in Dealings: "; $Body .= $ease; $Body .= "\n"; $Body .= "Information on Website: "; $Body .= $website; $Body .= "\n"; $Body .= "Industry Knowledge: "; $Body .= $knowledge; $Body .= "\n"; $Body .= "Recommendation: "; $Body .= $recommendation; $Body .= "\n"; $Body .= "Cost Efficency: "; $Body .= $cost; $Body .= "\n"; $Body .= "Service: "; $Body .= $service; $Body .= "\n"; $Body .= "How the respondent thinks Company can improve: "; $Body .= $improve; $Body .= "\n"; $Body .= "Why the respondent uses Company: "; $Body .= $reason; $Body .= "\n"; mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''); echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">'; ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 I'm guessing you haven't got error reporting turned on; $satisfiedservice = Trim(stripslashes($_POST[['satisfiedservice'])); $satisfiedresponse = Trim(stripslashes($_POST[['satisfiedresponse'])); $satisfiedadministration = Trim(stripslashes($_POST[['satisfiedadministration'])); $ease = Trim(stripslashes($_POST[['ease'])); $website = Trim(stripslashes($_POST[['website'])); $knowledge = Trim(stripslashes($_POST[['knowledge'])); $recommendation = Trim(stripslashes($_POST[['recommendation'])); $cost = Trim(stripslashes($_POST[['cost'])); $service = Trim(stripslashes($_POST[['service'])); $improve = Trim(stripslashes($_POST[['improve'])); $reason = Trim(stripslashes($_POST[['reason'])); Most of you're post arrays have two openning square brackets. [[ should be [ Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 I can't believe I missed that. Thank you so much for pointing out that horrific mistake. However, still no cigar. Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 add ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); Straight after your php tag '<?php' Also test the mail function: <?php if(mail(~details})) { echo 'sent'; } else { echo 'not sent'; } Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 Still throwing up a big, fat blank one. Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 If you did both things I just suggested you should either be getting a php error, or an output that we put in place, you get a blank screen? Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 my code now looks like <?php ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); $EmailTo = 'me@gmail.com'; $Subject = 'Customer Questionnaire'; $EmailFrom = 'response@client.net' $likelytorefer = Trim(stripslashes($_POST['likelytorefer'])); $continuebusiness = Trim(stripslashes($_POST['continuebusiness'])); $satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs'])); $satisfiedservice = Trim(stripslashes($_POST['satisfiedservice'])); $satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse'])); $satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration'])); $ease = Trim(stripslashes($_POST['ease'])); $website = Trim(stripslashes($_POST['website'])); $knowledge = Trim(stripslashes($_POST['knowledge'])); $recommendation = Trim(stripslashes($_POST['recommendation'])); $cost = Trim(stripslashes($_POST['cost'])); $service = Trim(stripslashes($_POST['service'])); $improve = Trim(stripslashes($_POST['improve'])); $reason = Trim(stripslashes($_POST['reason'])); $Body = ""; $Body .= "How likely the respondent is to recommend Company: "; $Body .= $likelytorefer; $Body .= "\n"; $Body .= "How likely the respondent is to continue business with Company:"; $Body .= $continuebusiness; $Body .= "\n"; $Body .= "How satisfied the respondent is with repairs: "; $Body .= $satisfiedrepairs; $Body .= "\n"; $Body .= "How satisfied the respondent is with service: "; $Body .= $satisfiedservice; $Body .= "\n"; $Body .= "How satisfied the respondent is with response times: "; $Body .= $satisfiedresponse; $Body .= "\n"; $Body .= "How satisfied the respondent is with administration service: "; $Body .= $satisfiedadministration; $Body .= "\n"; $Body .= "Ease in Dealings: "; $Body .= $ease; $Body .= "\n"; $Body .= "Information on Website: "; $Body .= $website; $Body .= "\n"; $Body .= "Industry Knowledge: "; $Body .= $knowledge; $Body .= "\n"; $Body .= "Recommendation: "; $Body .= $recommendation; $Body .= "\n"; $Body .= "Cost Efficency: "; $Body .= $cost; $Body .= "\n"; $Body .= "Service: "; $Body .= $service; $Body .= "\n"; $Body .= "How the respondent thinks Company can improve: "; $Body .= $improve; $Body .= "\n"; $Body .= "Why the respondent uses Company: "; $Body .= $reason; $Body .= "\n"; mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''); echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">'; if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''})) { echo 'sent'; } else { echo 'not sent'; } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 $EmailFrom = 'response@client.net' missing semi-colon mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''); echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">'; if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''})) { echo 'sent'; } else { echo 'not sent'; } should be if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''})) { echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">'; } else { echo 'not sent'; } Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 Ah, stupid me. Still coming up blank. My code is now: <?php ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); $EmailTo = 'me@gmail.com'; $Subject = 'Customer Questionnaire'; $EmailFrom = 'response@client.net'; $likelytorefer = Trim(stripslashes($_POST['likelytorefer'])); $continuebusiness = Trim(stripslashes($_POST['continuebusiness'])); $satisfiedrepairs = Trim(stripslashes($_POST['satisfiedrepairs'])); $satisfiedservice = Trim(stripslashes($_POST['satisfiedservice'])); $satisfiedresponse = Trim(stripslashes($_POST['satisfiedresponse'])); $satisfiedadministration = Trim(stripslashes($_POST['satisfiedadministration'])); $ease = Trim(stripslashes($_POST['ease'])); $website = Trim(stripslashes($_POST['website'])); $knowledge = Trim(stripslashes($_POST['knowledge'])); $recommendation = Trim(stripslashes($_POST['recommendation'])); $cost = Trim(stripslashes($_POST['cost'])); $service = Trim(stripslashes($_POST['service'])); $improve = Trim(stripslashes($_POST['improve'])); $reason = Trim(stripslashes($_POST['reason'])); $Body = ""; $Body .= "How likely the respondent is to recommend Company: "; $Body .= $likelytorefer; $Body .= "\n"; $Body .= "How likely the respondent is to continue business with Company:"; $Body .= $continuebusiness; $Body .= "\n"; $Body .= "How satisfied the respondent is with repairs: "; $Body .= $satisfiedrepairs; $Body .= "\n"; $Body .= "How satisfied the respondent is with service: "; $Body .= $satisfiedservice; $Body .= "\n"; $Body .= "How satisfied the respondent is with response times: "; $Body .= $satisfiedresponse; $Body .= "\n"; $Body .= "How satisfied the respondent is with administration service: "; $Body .= $satisfiedadministration; $Body .= "\n"; $Body .= "Ease in Dealings: "; $Body .= $ease; $Body .= "\n"; $Body .= "Information on Website: "; $Body .= $website; $Body .= "\n"; $Body .= "Industry Knowledge: "; $Body .= $knowledge; $Body .= "\n"; $Body .= "Recommendation: "; $Body .= $recommendation; $Body .= "\n"; $Body .= "Cost Efficency: "; $Body .= $cost; $Body .= "\n"; $Body .= "Service: "; $Body .= $service; $Body .= "\n"; $Body .= "How the respondent thinks Company can improve: "; $Body .= $improve; $Body .= "\n"; $Body .= "Why the respondent uses Company: "; $Body .= $reason; $Body .= "\n"; if(mail($EmailTo, $Subject, $Body, 'From: '.$EmailFrom.''})) { echo '<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.html">'; } else { echo 'not sent'; } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 That kind of makes no sense... do some little test all the way down. at the top add echo 'here'; If you see 'here' when you load the page take it down a few lines and try again... Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 There was no echo from the top, so I tried in IE out of curiosity and it's throwing me a 500 error that FireFox doesn't seem to want to display. Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 Then there's a problem with your server... Are you running locally, WAMP, LAMP, MAMP or are you testing this online? Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 testing online, on a client's server, so all I have is ftp access. Quote Link to comment Share on other sites More sharing options...
insomnia Posted July 8, 2009 Author Share Posted July 8, 2009 would it help to mention that the other mailing script they have is currently working just fine? I can use it as a last resort when I get lazy, but the email it produces isn't as neat as the one that would be produced from mine. the code for that one is: <?php // Simple Form Script // Copyright (C) 2005 Eric Zhang // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // Please send bugs/questions to erkzh@yahoo.com. //--------------------------Set these paramaters-------------------------- $subject = 'Website Enquiry'; // Subject of email sent to you. $emailadd = 'me@gmail.com'; // Your email address. This is where the form information will be sent. $url = 'http://www.form1.com.au/thankyou.html'; // Where to redirect after form is processed. $req = '1'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted July 8, 2009 Share Posted July 8, 2009 If there's other working, why dont you start again... <?php if(mail('youremail', 'test', 'test body')) { echo 'sent'; } else { echo 'not sent'; } ?> If it works keep adding, if/when you get stuck, report back! Quote Link to comment 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.