Ads901 Posted June 10, 2008 Share Posted June 10, 2008 Good Morning All I am very new to PHP, however through various forums I have built a simple PHP script to process a web form and then email it back to me, as well as redirecting the user to a thank you page. However when I run the script nothing happens - absolutely nothing (I have even tried adding the PHP action to show me errors but that doesnt even do anything). I have got the script checked and apparently there is no reason why it shouldnt work, but my web development is being held up by this at the moment. Here is a link to the form http://92.48.94.26/~theinval/market-monitor.co.uk/ig_contactus.html And here is the PHP script I have <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Contact Us Form Processor</title> </head> <body> <?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 = '[email protected]'; // Where to redirect after form is processed. $url = 'http://www.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: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> </body> </html> Can someone please help me!!!! Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/ Share on other sites More sharing options...
dmccabe Posted June 10, 2008 Share Posted June 10, 2008 Doesnt the page need to be saved as .php rather than .html? Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-561895 Share on other sites More sharing options...
Ads901 Posted June 10, 2008 Author Share Posted June 10, 2008 I thought that but was told that it makes no difference what the form page is saved as, as long as the script page is saved as PHP which it is...??? Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-561896 Share on other sites More sharing options...
dmccabe Posted June 10, 2008 Share Posted June 10, 2008 Yes but the php is within the HTML page, so it needs to PHP (I could be wrong, as my signature says I am no expert). Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-561898 Share on other sites More sharing options...
Ads901 Posted June 10, 2008 Author Share Posted June 10, 2008 The only reference in the form is the 'Action' property which is simply linked to the PHP script file - so I didn't think that the form itself had to be PHP it could just be HTML.... Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-561899 Share on other sites More sharing options...
dmccabe Posted June 10, 2008 Share Posted June 10, 2008 My appologies I was looking at that all wrong. Ignore me. Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-561900 Share on other sites More sharing options...
PFMaBiSmAd Posted June 10, 2008 Share Posted June 10, 2008 It is possible that the error reporting setting is set to not show all errors. Add this line as well - error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562079 Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 I ran the script with no problems. Hmmm..... Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562095 Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 What version of PHP do you have? Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562099 Share on other sites More sharing options...
Ads901 Posted June 10, 2008 Author Share Posted June 10, 2008 The host I use has got PHP 4 and 5 so it shouldnt be a problem. I have however worked out that currently the form used Spy validation for each field to ensure it is completed - however if you remove this then the script runs......any ideas of why this would be? Also on a side note I have a line in the PHP 'mail($emailadd, $subject, $text, 'From: '.$emailadd.'');' which at the moment means the from address is the same as the send address - do you nkow how i can change it to be the address of the peson submitting the form? Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562155 Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 Pull it from your Form. If you don't have a input for their email, make one. Also on a side note I have a line in the PHP 'mail($emailadd, $subject, $text, 'From: '.$emailadd.'');' which at the moment means the from address is the same as the send address - do you nkow how i can change it to be the address of the peson submitting the form? Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562158 Share on other sites More sharing options...
Ads901 Posted June 10, 2008 Author Share Posted June 10, 2008 I already have the field within my form - sorry but can you tell me what i need to put in the PHP to capture this - i am really new to it and i'm not sure how... Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562163 Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 We'd have to see your Form. Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562174 Share on other sites More sharing options...
Ads901 Posted June 10, 2008 Author Share Posted June 10, 2008 You can at this link http://92.48.94.26/~theinval/market-monitor.co.uk/ig_contactus.html Link to comment https://forums.phpfreaks.com/topic/109541-php-scripting-urgent-help/#findComment-562175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.