PHP contact form XHTML strict
#1
Posted 03 June 2008 - 12:45 PM
Thanks
#2
Posted 03 June 2008 - 01:03 PM
#3
Posted 03 June 2008 - 01:20 PM
Jem, on Jun 3 2008, 14:03, said:
Wow thanks Jem! You're a star
Quote
How right you are
#4
Posted 03 June 2008 - 01:44 PM
I love my little tagline - draws a lot of attention
#5
Posted 03 June 2008 - 02:14 PM
Jem, on Jun 3 2008, 14:44, said:
I love my little tagline - draws a lot of attention
OOOHhh it's beautiful!! Thank you!
I'd like to take the form and use it as an includes for my website. Do I need to change the form action to _SELF or something similar, or do I need to seperate the html and PHP into separate files so that the form calls the same PHP wherever in the site it appears? If so, can you help me figure it out?
Thanks again
#6
Posted 03 June 2008 - 03:26 PM
It's probably worth mentioning I've not actually tested that myself, mind
#7
Posted 03 June 2008 - 06:19 PM
Jem, on Jun 3 2008, 16:26, said:
It's probably worth mentioning I've not actually tested that myself, mind
It works! Thanks again!
#8
Posted 11 July 2008 - 07:53 PM
And is it based on Formmail or am i jus confused!
#9
Posted 31 July 2008 - 10:17 AM
$exploits =
$profanity =
$spamwords =
$bots =
aren't they a bad thing to have within your html page - won't they get indexed by google???
Not sure i'd want all those rude words within my HTML.
Any thoughts?
#10
Posted 31 July 2008 - 10:23 AM
Eskymo, on Jul 31 2008, 11:17, said:
$exploits =
$profanity =
$spamwords =
$bots =
aren't they a bad thing to have within your html page - won't they get indexed by google???
Not sure i'd want all those rude words within my HTML.
Any thoughts?
That part of the form is in PHP and will never appear in the users browsers (nor in the HTML source) - it'll never be seen.
Would it be possible for you to add in a Captcha, or a question "If I've got three apples, and I eat one - how many do I have left?" etc.
#11
Posted 31 July 2008 - 10:34 AM
I need a simple small form for a site I'm doing now, so will see how this works.
It would be good with a captcha - but I don't code php so not a job for me.
#12
Posted 31 July 2008 - 02:32 PM
Eskymo, on Jul 31 2008, 11:34, said:
I need a simple small form for a site I'm doing now, so will see how this works.
It would be good with a captcha - but I don't code php so not a job for me.
I might have a little bash
#13
Posted 31 July 2008 - 08:56 PM
i followed the instructions and inputted my email address and web address where it said, uploaded it, filled it out and pressed send and it's been over 15 minutes and I've still not received anything...
#14
Posted 31 July 2008 - 09:57 PM
The second test hasn't come through at all.
#15
Posted 31 July 2008 - 10:01 PM
#16
Posted 01 August 2008 - 03:36 PM
I just discovered this forum via Google while searching for a form I could create that would be XHTML Strict-compliant.
Jem, I used your free php mail-form and, although it both displays and functions correctly, when I go to check my page's validation, I get two errors.
Any idea how I can fix this so the contact form returns a valid compliance?
Thanks a million.
~ Jason ~
PS - This site looks fantastic, I'm so glad I found it.
#17
Posted 01 August 2008 - 03:54 PM
<fieldset>
<legend>Required Message:</legend>
<label for="comments">* Please type your message below:<br />
<textarea name="comments" id="comments" rows="6" cols="100" class="textbox"><?php get_data("comments"); ?></textarea></label><br />
</fieldset>
#18
Posted 02 August 2008 - 03:42 AM
Eskymo, on Aug 1 2008, 11:54, said:
<fieldset>
<legend>Required Message:</legend>
<label for="comments">* Please type your message below:<br />
<textarea name="comments" id="comments" rows="6" cols="100" class="textbox"><?php get_data("comments"); ?></textarea></label><br />
</fieldset>Ah, that did the trick! Thank you so much! I'm so glad I found this website
#19
Posted 19 September 2008 - 01:10 AM
#20
Posted 25 November 2008 - 09:33 AM
#21
Posted 25 November 2008 - 10:15 AM
if (preg_match_all("/<a|http:/i", implode($_POST))) { // check for <a and http:
echo "Naughty Spammer!"; exit();
}
#22
Posted 25 November 2008 - 10:23 AM
Quote
Email: nzgylvhj@lnvjqskq.com
Telephone: ELQATDqxdxlhB
Comments: Thanks!, adult affiliate click pay per, %O, adult learning style, %P, seven of nine adult, :-PPP, active adult community napa valley, 5470, pictures of heat rash in adults, 566614, adultery coping husband,
Submit: Send
Quote
Email: oxswokzo@oapmirqj.com
Telephone: ELQATDqxdxlhB
Comments: Thanks!, adult gay spanking, 226, adult personals quality, lhh, free adult online tv, ynvf, adult escort vacation, =-DDD, ruby adult film star, %), adult flick free hardcore, slp, adult services taiwan, jytuy, number of adult tooth, =PPP, adult exercise camp, 203, adult only resorts in las vegas, batvto, adult companion holiday, >:OOO,
Submit: Send
Quote
Email: qsyfoo@dvwgaj.com
Telephone: 539720788
Comments: vvxNF7 atiklmfyvfzv, qwxeqwxqbuab, [link=http://jhkocqxypgco.com/]jhkocqxypgco[/link], http://acpanniwkskr.com/
Submit: Send
Lots of rude stuff but also gobbledeegook...
#23
Posted 25 November 2008 - 06:14 PM
Thanks
E
#24
Posted 05 December 2008 - 08:53 PM
#25
Posted 08 December 2008 - 02:17 PM
mikejonesey, on Dec 6 2008, 04:53, said:
I give it a try (need more practice with xhtml codes. I can't figure out why it won't validates as xhtml 1.0 strict.)
php contact form with random math question. (with my sloppy codes,
Test run
Source files
#26
Posted 08 December 2008 - 03:00 PM
Eskymo, on Nov 25 2008, 18:14, said:
Thanks
E
I am ever so sorry, I didn't see that this thread had been updated while I took a break from this forum!
A mail form version 2 is in the works with more spam protection, but in the mean time if you want to try adding a simple question field it might help...
After the form textarea, add:
<label><input type="text" name="quiz" id="quiz" /> What colour is the sea?</label><br />
then change this bit:
$error_msg .= "That is not a valid e-mail address. \n"; }
to:
$error_msg .= "That is not a valid e-mail address. \n";
} elseif (empty($_POST['quiz']) || strtolower($_POST['quiz']) != "blue") {
$error_msg .= "Invalid answer to 'What colour is the sea?' \n";
}If you decide to change the question, don't forget to change "blue" to match the correct answer.
(Please note, I'm at work so haven't tested this but it should work!)
Edit: if anyone wants to play with version 2, you can grab it here:
http://www.jemjabell...ail_form_v2.txt
but note that it's still under construction.
#27
Posted 08 December 2008 - 04:32 PM
#28
Posted 22 February 2009 - 11:55 PM
Im not sure if its because ive been working to long or that i just f---ed up but all i get when i try to view my page in a browser (Other than the xhtml) is this
function clean($data) { $data = trim(stripslashes(strip_tags($data))); return $data; } // lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score.. // score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam :) $points = (int)0; $badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "****", "ejaculate", "fag", "felatio", "fellatio", "****", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "porn", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur"); $exploits = array("content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript"); foreach ($badwords as $word) if (strpos($_POST['comments'], $word) !== false) $points += 2; foreach ($exploits as $exploit) if (strpos($_POST['comments'], $exploit) !== false) $points += 2; if (strpos($_POST['comments'], "http://") === true || strpos($_POST['comments'], "www.") === true) $points += 2; elseif (isset($_POST['nojs'])) $points += 1; elseif (preg_match("/(<.*>)/i", $_POST['comments'])) $points += 2; elseif (strlen($_POST['name']) < 3) $points += 1; elseif (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500)) $points += 2; // end score assignments if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) { $error_msg .= "Name, e-mail and comments are required fields. \n"; } elseif (strlen($_POST['name']) > 15) { $error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n"; } elseif (!ereg("^[A-Za-z' -]*$", $_POST['name'])) { $error_msg .= "The name field must not contain special characters. \n"; } elseif (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($_POST['email']))) { $error_msg .= "That is not a valid e-mail address. \n"; } elseif (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url'])) $error_msg .= "Invalid website url."; if ($error_msg == NULL && $points <= $maxPoints) { $subject = "Automatic Form Email"; $message = "You received this e-mail message through your website: \n\n"; foreach ($_POST as $key => $val) { $message .= ucwords($key) . ": $val \r\n"; } $message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n"; $message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n"; $message .= 'Points: '.$points; if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) { $headers = "From: $yourEmail \r\n"; $headers .= "Reply-To: {$_POST['email']}"; } else { $headers = "From: $yourWebsite <$yourEmail> \r\n"; $headers .= "Reply-To: {$_POST['email']}"; } if (mail($yourEmail,$subject,$message,$headers)) { echo '
Your mail was successfully sent.
'; } else { echo '
Your mail could not be sent this time.
'; } } } function get_data($var) { if (isset($_POST[$var])) echo htmlspecialchars($_POST[$var]); } if ($error_msg != NULL) { echo '
ERROR:
'; echo nl2br($error_msg) . "
"; } ?>
Name: " />
E-mail: " />
Website URL: " />
Location: " />
Comments: <?php get_data("comments"); ?>All this is version 2 of the code mentioned earlier found here Version 2
I copied everything after the head tags in the script file and pasted it into the place i want the form to appear, i also changed the page file type from html to php.
I have absolutly no experience with php so i cant begin to think where i could have gone wrong, any ideas anyone?
#29
Posted 19 March 2009 - 09:42 PM
#30
Posted 24 July 2009 - 09:44 AM
"Your mail could not be sent this time."
I've checked everything and there's nothing that's wrong with my coding, Could it be my server not allowing it? (Free server).
http://gamerzone.uuuq.com/contact.php
#31
Posted 24 July 2009 - 09:49 AM
AdamConder, on 24 July 2009 - 09:44 AM, said:
"Your mail could not be sent this time."
I've checked everything and there's nothing that's wrong with my coding, Could it be my server not allowing it? (Free server).
http://gamerzone.uuuq.com/contact.php
Hi Adam,
What host are you with? Do they allow PHP?
#32
Posted 24 July 2009 - 09:51 AM
I have with: www.zymic.com (my domain is uuuq.com)
Thanks for the fast reply!
#33
Posted 24 July 2009 - 10:16 AM
AdamConder, on 24 July 2009 - 09:51 AM, said:
I have with: www.zymic.com (my domain is uuuq.com)
Thanks for the fast reply!
Unfortunately, I don't think Zymic support the Mail Function on their free web hosting. You will need to contact them to enable it, which costs about $10.
#34
Posted 24 July 2009 - 10:18 AM
#35
Posted 24 July 2009 - 10:23 AM
It's only to stop spammers signing up for free and abusing the system.
If you don't want to pay the $10, have a look at a service such as this:
Email me form
Hope it helps!
#36
Posted 01 August 2009 - 03:31 PM
Could I have a 'Thank you - message sent' message appear on the same page as the contact form rather than the form.php printing the message out seperately?
I'm new to php so any help would be appreciated
#38
Posted 25 August 2009 - 06:53 PM
#39
Posted 06 October 2009 - 11:27 AM
I presume the whole thing needs to go in one PHP file, rather than a HTML one linking to a PHP file? I have confirmation from the host that PHP is enabled and working. Anyway here it is (without styling or anything yet):
http://www.cttestare....uk/Contact.php
thanks
#40
Posted 06 October 2009 - 11:46 AM
<form action="NAMEOFPHPFILEHERE.php" method="post">
Help

























