August 15, 200818 yr Hi Guys. Can anyone tell me of any good resources to set up a PHP contact form? I've tried several online 'freebies' but I can never get them to work! My hosting supports PHP so not sure what the problem is.... As far as I know my hosting doesn't offer a cgi script to use either..... Hope someone could help, I really need to crack this! Sam
August 15, 200818 yr have you tried this one: http://www.jemjabella.co.uk/scripts/free-php-mail-form It is one of the easiest to set up and you can't really go wrong with it
August 15, 200818 yr Author have you tried this one: http://www.jemjabella.co.uk/scripts/free-php-mail-form It is one of the easiest to set up and you can't really go wrong with it Wow, that was quick. Thank you Dizi. Will check it out.... Sam
August 15, 200818 yr Author I swear by this one - http://css-tricks.com/nice-and-simple-contact-form/ Thanks 'fruit and veg' Will be sure to check this out as well, cheers for the reply.... Sam
August 15, 200818 yr Author Thanks 'fruit and veg' Will be sure to check this out as well, cheers for the reply.... Sam Hi 'fruit and veg'... I've been trying to get the contact form working but to no avail I have included my email address as the recipient and uploaded the relevant files.... Any idea as to why it's not working? I've copied the code below:- Sam <?php $EmailFrom = "chriscoyier@gmail.com"; $EmailTo = "samdelara@btinternet.com"; $Subject = "Nice & Simple Contact Form by CSS-Tricks"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contact-confirmation.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> <form action="contactengine.php" method="post"> <label for="Name">Name:</label><br /> <input type="text" name="Name" id="Name" cols="80" rows="6" /><br /><br /> <label for="Subject">Subject:</label><br /> <input type="text" name="Subject" id="Subject" cols="40" rows="6" /><br /><br /> <label for="email-address">Email-Address:</label><br /> <input type="text" name="email-address" id="email-address" cols="40" rows="6" /><br /><br /> <label for="Enquiry">Enquiry:</label><br /> <textarea name="Enquiry" id="Enquiry" cols="20" rows="6"></textarea><br /><br /> <input type="submit" name="submit" value="Submit" /> <input name="sort" type="hidden" id="sort" value="Name,Subject,email-address,Enquiry" /> </form>
August 15, 200818 yr the contact page is .php? contactengine.php is in the same folder as the contact page? You got a link to the page?
August 15, 200818 yr Author the contact page is .php? contactengine.php is in the same folder as the contact page? You got a link to the page? Hi, cheers for the reply...ummm, no the contact page is html but I've referenced the form to action the php file which is in the same directory, this should work shouldn't it? Link is here: http://samdelara.co.uk/contact2.html Sam
August 15, 200818 yr I completed the form and it worked OK. Are you not receiving the email? Double check the email address... $EmailFrom = "chriscoyier@gmail.com"; $EmailTo = "samdelara@btinternet.com"; $EmailFrom -0 can be anything, doesn't have to be an email address, this is the email's from line. $EmailTo - this should be correct, which according to your site, it is. and then your junk folder.
August 15, 200818 yr Author I completed the form and it worked OK. Are you not receiving the email? Double check the email address... $EmailFrom = "chriscoyier@gmail.com"; $EmailTo = "samdelara@btinternet.com"; $EmailFrom -0 can be anything, doesn't have to be an email address, this is the email's from line. $EmailTo - this should be correct, which according to your site, it is. and then your junk folder. Yep, email address is correct, spam folders checked and I also tried my google mail address.. Cannot understand why this won't work for me Any ideas? Is it my hosting perhaps? I know that PHP 5 is supported... Grrrrr......
August 15, 200818 yr Author Yep, email address is correct, spam folders checked and I also tried my google mail address.. Cannot understand why this won't work for me Any ideas? Is it my hosting perhaps? I know that PHP 5 is supported... Grrrrr...... Right, I'm really confused now - I have tested the PHP mail scripting funtion through my hosting control panel and it is working fine.....
August 15, 200818 yr I've just tested your code on my hosting and it works fine. Is your email working OK in general? If so, then it looks like your hosting is not emailing the message to you to begin with rather than it being an email problem.
August 15, 200818 yr Author I've just tested your code on my hosting and it works fine. Is your email working OK in general? If so, then it looks like your hosting is not emailing the message to you to begin with rather than it being an email problem. That's the strange thing, I don't think it is the hosting as their test scripts are working fine.....is there some sort of security measure that is preventing this script from working do you think? Sam
August 16, 200818 yr That's the strange thing, I don't think it is the hosting as their test scripts are working fine.....is there some sort of security measure that is preventing this script from working do you think? Sam Hi Sam, Two things you need to check. 1) smtp gateway is set 2) safe_mode is set to off You can check this by creating a file in notepad called test.php. Within this file put the following commands : <?php phpinfo(); ?> Then call test.php in your broswer. You should see a whole load of config settings for php. These are the settings and functions that your hosting provider allows you to do through php. Just do a search for smtp and safe_mode (Safe_mode is set to off and smtp has a gateway assigned to it). If these settings do not conform to what I stated then your hosting has disallowed it. But your hosting can block emails as a security measure because of spamming, in which case you need to tell them that you would like this service. Some times they may black list you because some one else has used your email address for spamming. Hope this helps and Good luck
August 17, 200818 yr (I didn't think php in .html files would work at all ) They don't HTML files with a form that post the data to a php script work
August 17, 200818 yr haha - that makes sense - thank you Mihai. I was on the verge of getting totally confused.
Create an account or sign in to comment