PDA

View Full Version : Help with fill-in form?



sacred_tinker
12-17-2008, 03:02 AM
Hey!

Well, I'm really new to coding and I'm stuck. I've recently created a fill-in form for my website and there are a few things I would like to fix but don't know how.

So far, all i have is a notice that says "Please submit a valid email address" (all it does is check if there is an "@" symbol and things like that) but i would like it to check if it is a registered/working email address as well.
Is there also a way of making sure that all of the fields in the form are filled in, before submission?

Also, is there a way of knowing if the "person/thing" on the other side that is entering the information into my form is really a person, and not some coded web robot or something?

Since my code is too long to fit into this box, here's the link to my webpage:
http://www.leopoldine-jpm.com/ttorder.htm

can someone please help me?

Nile
12-17-2008, 01:04 PM
Try this:
http://www.captcha.net/

sacred_tinker
12-18-2008, 12:50 AM
thank you! ^_^

but now im stuck because i don't know where to put what. >.<
My form is an HTML document with PHP working in the background. it's not PHP inside an HTML document.

http://recaptcha.net/plugins/php/

sacred_tinker
12-18-2008, 03:53 AM
okay. so after fiddling around with the codes, i finally managed to get the reCAPTCHA thingy working.

but how about:


So far, all i have is a notice that says "Please submit a valid email address" (all it does is check if there is an "@" symbol and things like that) but i would like it to check if it is a registered/working email address as well.
Is there also a way of making sure that all of the fields in the form are filled in, before submission?

Snookerman
12-18-2008, 06:36 AM
These might be helpful:
http://www.codewalkers.com/c/a/Email-Code/Checking-if-Email-address-is-deliverable/ (http://www.codewalkers.com/c/a/Email-Code/Checking-if-Email-address-is-deliverable/)
http://search.cpan.org/~rjbs/Email-Valid-0.179/lib/Email/Valid.pm (http://search.cpan.org/~rjbs/Email-Valid-0.179/lib/Email/Valid.pm)
http://authors.aspalliance.com/aspxtreme/abkd/script/valid_input.aspx (http://authors.aspalliance.com/aspxtreme/abkd/script/valid_input.aspx)

Nile
12-18-2008, 12:41 PM
This doesn't check if the email exists but it should validate it:


function is_valid_email($email){
if(preg_match("/[a-zA-Z0-9_\-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0){
return true;
}else{
return false;
}
}


Here's a code to see if the myemail@gmail.com is a valid(the site):


function is_real_site($email){
$email = preg_split("/[@]+/", $email);
$ip = $email[1];
exec("ping -n 4 $ip 2>&1", $output, $retval);
if ($retval != 0) {
$check = false;
} else {
$check = true;
}
return $check;
}

If so the function will return "1."
Inspired by: http://www.dynamicdrive.com/forums/showpost.php?p=164785&postcount=1

[edit]BUG IN ABOVE CODE! Someone could type: shutdown in the email address, and the server would shut down.

sacred_tinker
12-22-2008, 11:13 AM
well so far, i've got this checking the email address and it's doin a pretty good job at it:

<script language="JavaScript" type="text/javascript">
function validateForm(order)
{
//oForm refers to the form which you want to validate
order.onsubmit = function() // attach the function to onsubmit event
{
var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(order.elements['email'].value.length<1)
{
alert("Please enter your email address.");
return false;
}
else if(!regex.test(order.elements['email'].value))
{
alert("Please enter a valid email address.");
return false;
}
return true;
}
}
</script>

but it doesnt check the VALIDITY of anything, it just checks for typos. -_-

Nile: i tried entering your code but it doesnt work. :(