Ads901 Posted June 12, 2008 Share Posted June 12, 2008 Morning All I have got an online form, which you can see via this link http://92.48.94.26/~theinval/market-monitor.co.uk/ig_contactus.html It uses the below PHP form to process the form, sending it to an internal email address and redirecting to a thank you page. It is currently set out to use the email address that the user puts into the form as the 'From address' when it is sent - however when you submit the form you get the message 'Input is Empty' even though the email address is there. Can anyone explain how I can fix this? <?php ini_set('display_errors','On'); ?> <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Enquiry from the Market Monitor website'; // Your email address. This is where the form information will be sent. $emailadd = 'info@market-monitor.co.uk'; // Where to redirect after form is processed. $url = 'http://92.48.94.26/~theinval/market-monitor.co.uk/ig1_contactthankyou.html'; // 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. $req = '1'; // --------------------------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: '.$_POST["Email"].''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 12, 2008 Share Posted June 12, 2008 <?php mail($emailadd, $subject, $text, 'From: '.$_POST["Email"].''); ?> It seems like your last argument in the mail function may not be liked. mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) Taken from http://us3.php.net/manual/en/function.mail.php <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> So try setting a $header var, and making it: $headers = 'From: ' . $_POST['Email']; and then send your mail function like the php.net example: mail($emailadd, $subject, $text, $headers); Seems worth a try to start. Quote Link to comment Share on other sites More sharing options...
Ads901 Posted June 12, 2008 Author Share Posted June 12, 2008 Ok as I am new to PHP just to clarify - just add the headers in at the top of the current script, is that what your saying? What about the coding at the top that is already defining the to address, subject etc etc Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 12, 2008 Share Posted June 12, 2008 Sorry, let me apologize. I misread, I thought you were having a problem with the mail function, not getting a $_POST value populated. You should haven't to change anything yet from what I've said, apologies. If it's telling you that the "email" section of the form is missing you could do a few debug things. One would be a print_r($_POST) to show all the post values entered. Verify that you're receiving a $_POST['Email'] field with some value. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 12, 2008 Share Posted June 12, 2008 I think I found the problem, or at least where to look. Shows on line 193ish for me. You can search your code for <input name="input" type="checkbox" value=""> <-- This is what is showing up empty It seems your checkboxes are screwy. When I select "No" for ?Receive email updates?, it selects both yes and no. You should either have one check box for "Yes", where unchecked == no. Or use a RADIO button instead to avoid confusion. Fix this section~ <tr> <td class="Form_Headings">Would you like to recieve future email updates?</td> <td><label><span id="spryEmailUpdates"> <input type="checkbox" name="Email Updates Yes" id="EmailUpdatesYes"> <span class="Typestyle_body">Yes</span><span class="Typestyle_body"> <input name="input" type="checkbox" value=""> No</span> <span class="checkboxRequiredMsg">Please make a selection.</span></span></label></td> </tr> 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.