PHP Form not working |
PHP Form not working |
M4rshall |
Mar 10 2014, 01:32 PM
Post
#1
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Hi all,
I obtained a free form and I have made several changes to its content and the form isn't working. I have gone back to the original file I obtained which contained - Form Page, Thank You Page, PHP Process, PHP Install Page, CSS Style Sheet & some installation text. I have changed the questions in the form & stripped the branding (questions are now - Name, email address, Ref number, a yes/no drop down menu & further information - the Anti Spam question has been removed). I've updated the PHP process to follow the new changes, the CSS file has been replaced the company style & the form loads and look exactly as I need it to. However I am yet to change the install file as when I have gone back to the original files I obtained to test them and I can't get that one to work. I load the Form, click submit and the PHP process is displayed in browser. I have gone to the install text file and followed it suggested process to open the browser, open the install file and jobs should be a good one. However all that happens is IE or Chrome prompts me that the files is downloading and to open it, when I do that the process repeats (download open, download open etc.) unless I click cancel. If anybody can help it would be greatly appreciated - below is the contents of the original files, I can not show my changed files (content & branding) for legal reasons. If anyone could point out any errors in these originals or direction in my errors that would be amazing. Form Page <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Contact Us</title> <script src="freecontactformvalidation.js"></script> <script> required.add('Full_Name','NOT_EMPTY','Full Name'); required.add('Email_Address','EMAIL','Email Address'); required.add('Your_Message','NOT_EMPTY','Your Message'); required.add('AntiSpam','NOT_EMPTY','Anti-Spam Question'); </script> <link rel="stylesheet" type="text/css" href="freecontactform.css"> </head> <body> <form name="freecontactform" method="post" action="freecontactformprocess.php" onsubmit="return validate.check(this)"> <table width="400px" class="freecontactform"> <tr> <td colspan="2"> <div class="freecontactformheader">Contact Us Form</div> <div class="freecontactformmessage">Fields marked with <span class="required_star"> * </span> are mandatory.</div> </td> </tr> <tr> <td valign="top"> <label for="Full_Name" class="required">Full Name<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Email_Address" class="required">Email Address<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Telephone_Number" class="not-required">Telephone Number</label> </td> <td valign="top"> <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Your_Message" class="required">Your Message<span class="required_star"> * </span></label> </td> <td valign="top"> <textarea style="width:230px;height:160px" name="Your_Message" id="Your_Message" maxlength="2000"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center" > <div class="antispammessage"> To help prevent automated spam, please answer this question <br /><br /> <div class="antispamquestion"> <span class="required_star"> * </span> Using only numbers, what is 10 plus 15? <input type="text" name="AntiSpam" id="AntiSpam" maxlength="100" style="width:30px"> </div> </div> </td> </tr> <tr> <td colspan="2" style="text-align:center" > <br /><br /> <input type="submit" value=" Submit Form " style="width:200px;height:40px"> <br /><br /> <br /><br /> </td> </tr> </table> </form> </body> </html> Install PHP <?php define('INSTALLFILE', 'freecontactforminstall.php'); define('CONFIGFILE', 'freecontactformsettings.php'); define('ABSPATH', dirname(__FILE__) . '/' ); error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); $install_complete = '<br />Installation complete. <a href="contactform.htm">Visit your form</a>. <br /><br />To reinstall, delete the file: '.CONFIGFILE.' then run <a href="'.INSTALLFILE.'">this installer again</a>.<br /><br />'; $config_template = '<?php $email_to = "{EMAIL}"; // your email address $email_subject = "{SUBJECT}"; // email subject line $thankyou = "{THANKYOU}"; // thank you page // if you update the question on the form - // you need to update the questions answer below $antispam_answer = "{ANSWER}"; ?>'; if(isset($_POST['step'])) { $step = $_POST['step']; } else { $step = 1; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Installation</title> <link rel="stylesheet" type="text/css" href="freecontactform.css"> <style>.freecontactform {width: 460px;font-size:12px}</style> </head> <body> <div align="center"><br /> <div class="freecontactform"> <div class="freecontactformheader">Installation Form</div> <?php switch($step) { case "1": if ( file_exists( ABSPATH . CONFIGFILE) ) { // The config file resides in ABSPATH // require_once( ABSPATH . CONFIGFILE ); echo $install_complete; } else { ?> <script src="freecontactformvalidation.js"></script> <script> required.add('email','EMAIL','Email Address'); required.add('subject','NOT_EMPTY','Subject Line'); required.add('thankyou','NOT_EMPTY','Redirect Page'); </script> <form name="freecontactform" method="post" action="<?php echo INSTALLFILE; ?>" onsubmit="return validate.check(this)"> <input type="hidden" name="step" value="2"> <table width="450px"> <tr> <td colspan="2"> <div class="freecontactformmessage"> Your configuration file does not exist at:<br /><br /> <?php echo ABSPATH.CONFIGFILE; ?>.<br /><br /> Create it now!.<br /><br /> </td> </tr> <tr> <td valign="top"> <label for="email" class="required">Email Address<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="email" id="email" maxlength="100" style="width:180px"> </td> </tr> <tr> <td valign="top"> <label for="subject" class="required">Subject Line<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="subject" id="subject" maxlength="100" value="Contact form submission" style="width:180px"> </td> </tr> <tr> <td valign="top"> <label for="thankyou" class="required">Redirect Page<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="thankyou" id="thankyou" maxlength="100" value="thankyou.htm" style="width:180px"> </td> </tr> <tr> <td valign="top"> <label for="answer" class="required">Antispam Answer<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="answer" id="answer" maxlength="100" value="25" style="width:180px"> </td> <tr> <td colspan="2" style="text-align:center" > <br /><br /> <input type="submit" value=" Install My Form " style="width:200px;height:40px"> <br /><br /> </td> </tr> </table> </form> <?php } break; case "2": $error_strings = array(); if(!file_exists(ABSPATH.CONFIGFILE)) { $config_data = str_replace( array( "{EMAIL}", "{SUBJECT}", "{THANKYOU}", "{ANSWER}"), array( $_POST['email'], $_POST['subject'], $_POST['thankyou'], $_POST['answer'] ), $config_template ); // generate config if(!$config_h = fopen(ABSPATH.CONFIGFILE,"wb")) { $viewable_code = nl2br(str_replace("<","<",$config_data)); $error_strings[] = "Cannot write your configuration file to: ".ABSPATH.CONFIGFILE." - Please change the directory permissions to allow write access.<br /><br /> If you prefer, you can create the configuration file using the code below:<br /><br />".$viewable_code."<br /><br />Save the above code to a new file at: ".ABSPATH.CONFIGFILE; } else { if(!fwrite($config_h, trim($config_data))){ $viewable_code = nl2br(str_replace("<","<",$config_data)); $error_strings[] = "Cannot write your configuration file to: ".ABSPATH.CONFIGFILE." - Please change the directory permissions to allow write access.<br /><br /> If you prefer, you can create the configuration file using the code below:<br /><br />".$viewable_code."<br /><br />Save the above code to a new file at: ".ABSPATH.CONFIGFILE; } fclose($config_h); } } if(count($error_strings) > 0) { foreach($error_strings as $es) { echo "$es <br />"; } } else { echo $install_complete; } break; } ?> <br /><br /> </div> </div> </body> </html> PHP process <?php if(isset($_POST['Email_Address'])) { include 'freecontactformsettings.php'; function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Telephone_Number']) || !isset($_POST['Your_Message']) || !isset($_POST['AntiSpam']) ) { died('Sorry, there appears to be a problem with your form submission.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $telephone = $_POST['Telephone_Number']; // not required $comments = $_POST['Your_Message']; // required $antispam = $_POST['AntiSpam']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if($antispam <> $antispam_answer) { $error_message .= 'The Anti-Spam answer you entered is not correct.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Telephone: ".clean_string($telephone)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php } die(); ?> Install Text Installation of the Free version: METHOD 1 (Automatted) Upload all files to your website. In your browser, open the file freecontactforminstall.php and install. METHOD 2 (Manual) Create the file 'freecontactformsettings.php' using a code/plain text Editor. Insert the following code into this file :- <?php $email_to = "youremailaddress@yourdomain.com"; // your email address $email_subject = "Contact Form Message"; // email subject line $thankyou = "thankyou.htm"; // thank you page // if you update the question on the form - // you need to update the questions answer below $antispam_answer = "25"; ?> Enter your email address in place of youremailaddress@yourdomain.com Change the email subject (if you like) Change your thank you page reference (if you like) Save the file. Copy ALL files onto your website using an FTP program (filezilla for example) =========== |
Christian J |
Mar 10 2014, 03:17 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,649 Joined: 10-August 06 Member No.: 7 |
This looks like a rather convoluted email form, so I haven't examined it closer.
QUOTE I load the Form, click submit and the PHP process is displayed in browser. I have gone to the install text file and followed it suggested process to open the browser, open the install file and jobs should be a good one. However all that happens is IE or Chrome prompts me that the files is downloading and to open it The above sounds like the PHP isn't parsed by the server's PHP engine. Does your web host support PHP? Which file extension do you use for your PHP files? You can test this by creating a file named say phpinfo.php, which just contains this: CODE <?php phpinfo(); ?> (if PHP is supported you should see a lot of configuration settings in your browser). BTW there might be some confusion in terminology. Usually we talk about PHP files and PHP scripts (or server-side scripts, or form handling scripts). Not sure what a "PHP process" is, but in this case it's probably just a file name the script author used. |
jimlongo |
Mar 10 2014, 05:48 PM
Post
#3
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
Bizzare that it requires an install.php to configure 3 settings.
Well I guess maybe that's to make is simple for people who shouldn't be using it in the first place. Forget the installation and do the manual install. Comment out all the anti spam lines in 'freecontactformsettings.php', should look like this. CODE <?php $email_to = "youremailaddress@yourdomain.com"; // your email address $email_subject = "Contact Form Message"; // email subject line $thankyou = "thankyou.htm"; // thank you page //$antispam_answer = "25"; if(isset($_POST['Email_Address'])) { include 'freecontactformsettings.php'; function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if( !isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Telephone_Number']) || !isset($_POST['Your_Message']) ) { died('Sorry, there appears to be a problem with your form submission.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $telephone = $_POST['Telephone_Number']; // not required $comments = $_POST['Your_Message']; // required //$antispam = $_POST['AntiSpam']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } // if($antispam <> $antispam_answer) { // $error_message .= 'The Anti-Spam answer you entered is not correct.<br />'; // } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Telephone: ".clean_string($telephone)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php } die(); ?> This post has been edited by jimlongo: Mar 10 2014, 05:54 PM |
M4rshall |
Mar 11 2014, 05:41 AM
Post
#4
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Thanks Christian.
The website is an internal intranet site for the employees of the company. The intention of the form is for employees to be able to log a verbal complaint with the complaints team via filing this form out which will in theory will generate an email to complaint team. The site is hosted on its own server & it is has the PHP programme installed by our global IT team. I have created the testing file you suggest and I am getting the same download, open loop when I use my form. I am fairly new to server-side scripting but any and all help would be greatly appreciated. |
jimlongo |
Mar 11 2014, 08:47 AM
Post
#5
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
You need to ask your global IT team why the server is not parsing your php file properly.
|
Christian J |
Mar 11 2014, 08:53 AM
Post
#6
|
. Group: WDG Moderators Posts: 9,649 Joined: 10-August 06 Member No.: 7 |
The site is hosted on its own server & it is has the PHP programme installed by our global IT team. I have created the testing file you suggest and I am getting the same download, open loop when I use my form. Do you use the correct URL to request the page? Perhaps it's something like http://localhost/test.php or http://yoursite/test.php (ask your IT department). It could also be that the page is served with an incorrect or missing Content-type header, so that browsers don't recognize it as HTML. I don't know if you can check that from your browser on a local server, though. In any case you can't open pages directly from the file system (like file://localhost/C:/Users/Yourname/Documents/test.php or C:/Users/Yourname/Documents/test.php ) if you want them to be processed by a server-side script like PHP, and such files with .php extensions may not be recognized as web pages at all by a browser. |
M4rshall |
Mar 11 2014, 10:19 AM
Post
#7
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Christian,
I have followed your instructions last and accessed the page in chrome via going to the home page and change it from file:///Y:/home.html to file:///Y:/phpinfo.php The page loads and displays the text in the PHP script you suggested above. <?php phpinfo(); ?> When I follow the same process in IE I get the download open loop again! Any ideas what this is telling me / you? |
M4rshall |
Mar 11 2014, 10:22 AM
Post
#8
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
I've just RDM'ed on to the server and tried the same as above in IE and I get the page opening and showing me the coding.
This post has been edited by M4rshall: Mar 11 2014, 10:28 AM |
M4rshall |
Mar 11 2014, 10:27 AM
Post
#9
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Jimlongo - yes this may be a stupid question but what do you mean by parsing?
Apologise as above I new to server side scripting. This post has been edited by M4rshall: Mar 11 2014, 10:28 AM |
M4rshall |
Mar 11 2014, 10:37 AM
Post
#10
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Just digging in to my emails where the IT desk informed me that PHP had been installed and this is the content of the email -
I am being informed that PHP 5.5.6 is not compatible with the Leeds Intranet Server OD, i.e. Windows 2003. The latest version for this OS is PHP 5.4.22. PHP has been configured on **SERVERNAME**04. It has been configured as - http://**SERVERPATH**/xampp/ And http://**SERVERPATH**/xampp/ this is a link that opens a webpage like programme...... Again apologise for the dense-ness here just trying to give you guys as much information for you to be able to offer me your help and ideas.... This post has been edited by M4rshall: Mar 11 2014, 10:39 AM |
jimlongo |
Mar 11 2014, 10:45 AM
Post
#11
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
The version of PHP is fine. Try the following, of course changing **SERVERPATH** as appropriate
http://**SERVERPATH**/xampp/test.php http://**SERVERPATH**/xampp/freecontactformsettings.php |
M4rshall |
Mar 11 2014, 10:56 AM
Post
#12
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Thanks Jimlongo....
http://**SERVERPATH**/xampp/phpinfo.php has worked and display a mass of information What's the next step in getting my php to work? This post has been edited by M4rshall: Mar 11 2014, 11:24 AM |
jimlongo |
Mar 11 2014, 11:28 AM
Post
#13
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
Put the php file I posted earlier in a file called freecontactformprocess.php (you need to change the variables at the top to your email, etc., )
The put this code in a file called form.html Put both files on the server. Go to http://**SERVERPATH**/xampp/form.html - fill it out and see if it works. CODE <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Contact Us</title> <script src="freecontactformvalidation.js"></script> <script> required.add('Full_Name','NOT_EMPTY','Full Name'); required.add('Email_Address','EMAIL','Email Address'); required.add('Your_Message','NOT_EMPTY','Your Message'); //required.add('AntiSpam','NOT_EMPTY','Anti-Spam Question'); </script> <link rel="stylesheet" type="text/css" href="freecontactform.css"> </head> <body> <form name="freecontactform" method="post" action="freecontactformprocess.php" onsubmit="return validate.check(this)"> <table width="400px" class="freecontactform"> <tr> <td colspan="2"> <div class="freecontactformheader">Contact Us Form</div> <div class="freecontactformmessage">Fields marked with <span class="required_star"> * </span> are mandatory.</div> </td> </tr> <tr> <td valign="top"> <label for="Full_Name" class="required">Full Name<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Email_Address" class="required">Email Address<span class="required_star"> * </span></label> </td> <td valign="top"> <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Telephone_Number" class="not-required">Telephone Number</label> </td> <td valign="top"> <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:230px"> </td> </tr> <tr> <td valign="top"> <label for="Your_Message" class="required">Your Message<span class="required_star"> * </span></label> </td> <td valign="top"> <textarea style="width:230px;height:160px" name="Your_Message" id="Your_Message" maxlength="2000"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center" > <!-- <div class="antispammessage"> To help prevent automated spam, please answer this question <br /><br /> <div class="antispamquestion"> <span class="required_star"> * </span> Using only numbers, what is 10 plus 15? <input type="text" name="AntiSpam" id="AntiSpam" maxlength="100" style="width:30px"> </div> --> </div> </td> </tr> <tr> <td colspan="2" style="text-align:center" > <br /><br /> <input type="submit" value=" Submit Form " style="width:200px;height:40px"> <br /><br /> <br /><br /> </td> </tr> </table> </form> </body> </html> This post has been edited by jimlongo: Mar 11 2014, 11:50 AM |
M4rshall |
Mar 11 2014, 11:34 AM
Post
#14
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Please see my changed Form & PHP process - I've gone over it and removed the company branding & content.
COMPLAINT FORM.HTML <br> <script> required.add('Your_Name','NOT_EMPTY','Your Name'); required.add('Your_Email_Address','EMAIL','Your Email Address'); required.add('**COMPANY NAME**_Referance_Number','NOT_EMPTY','**COMPANY NAME** Referance Number'); required.add('Complaint_Details','NOT_EMPTY','Complaint Details'); required.add('Resolved?','NOT_EMPTY','Resolved?'); required.add('Further_Action_Required?','NOT_EMPTY','Further Action Required?'); </script> <form name="Complaint Form" method="post" action="Complaintform.php" onsubmit="return validate.check(this)"> <table class="Complaintform" style="opacity:0.7"> <tr> <td colspan="2"> <div class="Complaintformheader"><font color="#ffffff">Submit a Customer Complaint using this form</div> <div class="Complaintformmessage"><font color="#ffffff">Fields marked with * are mandatory.</div> </td> </tr> <tr> <td valign="top"> <label for="Your_Name" class="required"><font color="#ffffff">Your Name *</label> </td> <td valign="top"> <input type="text" name="Your_Name" id="Full_Name" maxlength="100" style="width:420px"> </td> </tr> <tr> <td valign="top"> <label for="Your_Email_Address" class="required"><font color="#ffffff">Your Email Address *</label> </td> <td valign="top"> <input type="text" name="Your_Email_Address" id="Your_Email_Address" maxlength="200" style="width:420px"> </td> </tr> <tr> <td valign="top"> <label for="**COMPANY NAME**_Referance_Number" class="required"><font color="#ffffff">**COMPANY NAME** Referance Number *</label> </td> <td valign="top"> <input type="text" name="**COMPANY NAME**_Referance_Number" id="**COMPANY NAME**_Referance_Number" maxlength="50" style="width:420px"> </td> </tr> <tr> <td valign="top"> <label for="Complaint_Details" class="required"><font color="#ffffff">Complaint Details *</label> </td> <td valign="top"> <textarea style="width:420px;height:150px" name="Complaint_Details" id="Complaint_Details" maxlength="4000"></textarea> </td> </tr> <tr> <td valign="top"> <label for="Resolved?" class="required"><font color="#ffffff">Resolved?*</label> </td> <td valign="top"> <select> <option>Yes</option> <option>No</option> </select> </td> </tr> <tr> <td valign="top"> <label for="Further_Action_Required?" class="required"><font color="#ffffff">Further Action Required?*</label> </td> <td valign="top"> <textarea style="width:420px;height:150px" name="Further_Action_Required?" id="Further_Action_Required?" maxlength="4000"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <br /> <input type="submit" value=" Submit Form " style="width:440px;height:40px"> <br /><br /> </td> </tr> </table> </form> <br> COMPLAINT FORM.PHP <?php if(isset($_POST['Email_Address'])) { function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if(!isset($_POST['Your_Name']) || !isset($_POST['Your_Email_Address']) || !isset($_POST['**COMPANY NAME**_Referance_Number']) || !isset($_POST['Complaint_Details']) || !isset($_POST['Resolved?']) !isset($_POST['Further_Action_Required?']) ) { died('Sorry, there appears to be a problem with your form submission.'); } $Your_Name = $_POST['Your_Name']; // required $Your_Email_Address = $_POST['Your_Email_Address']; // required $**COMPANY NAME**_Referance_Number = $_POST['**COMPANY NAME**_Referance_Number']; // required $Complaint_Details = $_POST['Complaint_Details']; // required $Resolved? = $_POST['Resolved?']; // required $Further_Action_Required? = $_POST['Further_Action_Required?']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($your_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($Complaint_details) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if($antispam <> $**COMPANY NAME**_referance_number) { $error_message .= 'You have not input a **COMPANY NAME** Referance Number.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:"); return str_replace($bad,"",$string); } $email_message .= "Your Name: ".clean_string($your_name)."\r\n"; $email_message .= "Email: ".clean_string($your_email_address)."\r\n"; $email_message .= "**COMPANY NAME** Referance Number: ".clean_string($**COMPANY NAME**_Referance_Number)."\r\n"; $email_message .= "Complaint Details: ".clean_string($Complaint_Details)."\r\n"; $email_message .= "Resolved?: ".clean_string($Resolved?)."\r\n"; $email_message .= "Further Action Required?: ".clean_string($Further_Action_Required?)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php } die(); ?> |
M4rshall |
Mar 11 2014, 11:51 AM
Post
#15
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Jimlongo -
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Contact Us</title> <script src="freecontactformvalidation.js"></script> <script> required.add('Full_Name','NOT_EMPTY','Full Name'); required.add('Email_Address','EMAIL','Email Address'); required.add('Your_Message','NOT_EMPTY','Your Message'); //required.add('AntiSpam','NOT_EMPTY','Anti-Spam Question'); </script> <link rel="stylesheet" type="text/css" href="freecontactform.css"> </head> <body> <form name="freecontactform" method="post" action="freecontactformprocess.php" I am correct in changing action to read action="SERVERNAME/XAMPP/Complaintform.php" |
jimlongo |
Mar 11 2014, 11:52 AM
Post
#16
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
You need the action to point to the php file. If it's on the same server in the same folder it can be
action="freecontactformprocess.php" Also while troubleshooting you might put this at the top (after the opening php tag) of the freecontactformprocess.php code to see errors. error_reporting(E_ALL); This post has been edited by jimlongo: Mar 11 2014, 11:55 AM |
M4rshall |
Mar 11 2014, 12:04 PM
Post
#17
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
I have put the following files on the server where all the other webpages sit -
Complaintform.php Complaints Form.html Complaints Thank You.html I have also updated the PHP file to my email address in the interim for testing purposes & the form action is pointing to the PHP file as action="Complaintform.php" When I go to my form and fill it out I click submit and the page displays the PHP file coding - no emails come to me & the thank you page does not load. |
jimlongo |
Mar 11 2014, 12:37 PM
Post
#18
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
Well you keep changing names, so make sure of this.
1. I'd suggest, can we remove the spaces and make everything lowercase to begin with. complaint-form.php complaints-form.html complaints-thank-you.html 2. now in the complaints-form.html the action="complaint-form.php" 3. the variable $thankyou = "complaints-thank-you.html"; You seem to be missing parts of the code in the recent examples you submitted. Make sure you haven't removed the variables in the php script. Look at the example I posted earlier, you need those variables at the top. |
M4rshall |
Mar 11 2014, 12:39 PM
Post
#19
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
So I've access the page via the full web address rather just opening the html file on the drive. Gone to the form, filled it out and hit submit button - Accessing it this way I get -
The page cannot be displayed The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. Please try the following: Contact the Web site administrator if you believe that this request should be allowed. Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. HTTP Error 405 - The HTTP verb used to access this page is not allowed. Internet Information Services (IIS) Technical Information (for support personnel) Go to Microsoft Product Support Services and perform a title search for the words HTTP and 405. Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Setting Application Mappings, Securing Your Site with Web Site Permissions, and About Custom Error Messages. Again i assume its do with not being able to read the PHP but I don't know. |
M4rshall |
Mar 11 2014, 12:41 PM
Post
#20
|
Member Group: Members Posts: 60 Joined: 8-August 13 Member No.: 19,534 |
Sorry for the name changes - i first upload the content from the original form I obtained on the net. I have then gone over my script removed references to the company I work for and uploaded my amended scripts to make it so we can try and solve this on the actual live documents.
Jimlongo could I ask a massive favour that you could repost/rewrite the script I should used based on my amended scripts? If you can't (don't have the time or just don't want to), don't worry I will try again tomorrow and let you know how I get on. Thank you for the help and suggestions so far - I do appreciate it. This post has been edited by M4rshall: Mar 11 2014, 12:45 PM |
Lo-Fi Version | Time is now: 17th April 2024 - 02:10 PM |