SEO Services
Home >> Webmaster Forums >> checkemail

checkemail


Sharky said: "this will not work any ideas? else if (checkemail($from) == false) echo "Your email address is not valid please enter it again";"

chris3471 said: "Could be wrong but try this, I just removed the "if" else (checkemail($from) == false) echo "Your email address is not valid please enter it again";"

Sharky said: "im quite sure you need the 'if'"

chris3471 said: "I thought the if and else were two opposite statements?"

Sharky said: "[code] if ($from == "" || $name == "" || $subject == "" || $message == "") echo "You did not enter all the fields please go back and enter them."; else if ($ip == "213.249.155.") echo "$name your ip address has been blocked."; else if (stristr($badword, $message)) echo "you are not allowed to send this message due to the language you have used."; else if (mail($to, $subject, $body, "From: $from")) echo "Message was send, thank you $name for your message.
You will be redirected to the homepage. "; [/code] it works but when i add a the checkemail it doesnt :confused:"

chris3471 said: "Found this don't know if you can use it though. Validate Email Address in PHP - PHP - It’s a common task but one that I haven’t looked at in as much detail as this devshed article. There’s a few bugs in the code, and a function was posted to the comments that’s all over the place.. here’s the same PHP function, cleaned up, to verify an email address. Note that it won’t work in Windows as-is because “checkdnsrr()” isn’t available on Windows platforms. (Remove the \ characters from before the ” characters surrounding the regex.. WordPress adds them when I post this. *grrr*) function checkEmail($email) { // checks proper syntax if( !preg_match( \"/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/\", $email)) { return false; } // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS $mxhosts = array(); if(!getmxrr($domain, $mxhosts)) { // no mx records, ok to check domain if (!fsockopen($domain,25,$errno,$errstr,30)) { return false; } else { return true; } } else { // mx records found foreach ($mxhosts as $host) { if (fsockopen($host,25,$errno,$errstr,30)) { return true; } } return false; } }"

Sharky said: "theres one like that on phpfreaks.com but i want this small one to work mainly because it is smaller :D"

Neutron2k said: "ok ChrisL if and else are not opposite statements. they are conditional. at the very least you must have an IF condition if then you can use an elseif or an else to finish off e.g. if($bigtonyiq == 2) { //do somthing } elseif($bigtonyiq==4) { //do somthing } else { //do somthing else } SHARKY: validate forms with javascript first if you can. also check the functions work when you pass hard coded things to them before attempting operator overloading."

chris3471 said: "[QUOTE=Neutron2k]ok ChrisL if and else are not opposite statements. they are conditional. at the very least you must have an IF condition if then you can use an elseif or an else to finish off e.g. if($bigtonyiq == 2) { //do somthing } elseif($bigtonyiq==4) { //do somthing } else { //do somthing else } SHARKY: validate forms with javascript first if you can. also check the functions work when you pass hard coded things to them before attempting operator overloading.[/QUOTE] I know, I did a little research today after Sharky said you need the IF. :eek: And Big Tony is 2. :eek:"

edwin said: "[code] if ($bigtonyiq > 0) { echo "

houston, we have a problem.

"; } [/code] sharky, where is your function "checkemail"?"

Sharky said: "this is it with the checkemail in it [code] $to = "**********"; $name = $_POST['name']; $from = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $ip = $_POST['ip']; $body = "$message \n\nName: $name \nEmail: $from \nSubject: $subject \nIP: $ip"; $banned = "'123.123.123.123' || '123.123.123.123'"; if (checkemail($from) == FALSE) echo "email address is not valid"; else if ($from == "" || $name == "" || $subject == "" || $message == "") echo "You did not enter all the fields please go back and enter them."; else if ($ip == $banned) echo "Message not sent"; else if (mail($to, $subject, $body, "From: $from")) echo "Message was send, thank you $name for your message.
You will be redirected to the homepage.
"; [/code] i think that was it if it is im glad i coud remember it :D"

Neutron2k said: "no sharky, we need to code for the function called checkemail()"

Sharky said: "does that mean i need more code i cant just use it on its own?"

Neutron2k said: "wake up sharky that code above is calling to a function called CHECKEMAIL, but you havnt given us the code listing for the CHECKEMAIL function. in that code in your last post, there is no such thing as the checkemail function before you havnt written it."

Sharky said: "ive never used functions, i just thought it was a wierd checkemail thing that didnt need any script. i'll read about functions now"

Neutron2k said: "well thats why it isnt working. checkemail is not a standard php/asp/javascript function. you would have to write a function called checkemail or it won't work and you will get a server/scripting error."

Sharky said: "right lol so how would i wright it i cant find any tutorials and no other functions are helping :confused:"

Neutron2k said: "what exactly do you want the check email function to do? :confused:"

chris3471 said: "He told me he want's to check to see if an email address exists. So people can't just submit a phony address."

edwin said: "so now we're getting a bit more advanced. that's why i asked. checkemail is a function call, so somewhere in your code, or in an include file, you will need this: [code] function checkemail($address) { // do something here } [/code] this function will be one that ensures that the email is valid. for this you will do pattern_matching. you also need an error array for displaying messages, so this code is getting to be a lot of work. this is why is use quickform (because all of the error checking is installed already)"

chris3471 said: "Tell us more. :eek:"

Neutron2k said: "there is no way to check is an email address is valid. you can check it has the correct elements to make it a potentially valid email adddress, but the only way to find out if it is real is to email it."

Sharky said: "so how would i check it has the @ in it then or only allow .com .co.uk .org etc"

Neutron2k said: "you would need to search the string for the characters. validate with javascript. its a lot easier and there are a load of scripts to do that."

chris3471 said: "Something like this right. function checkEmail($email) { // checks proper syntax if( !preg_match( \"/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/\", $email)) { return false; }"

Neutron2k said: "thats a very long regular expression there."

Sharky said: "sorry but i would rather not use javascript it will muddle up php for me as im learning that at the moment. i copyed one of phpfreaks [url]http://www.phpfreaks.com/quickcode/E-Mail-Address-Validator-Easy/515.php[/url] i dont really like copying so im going to learn everything about it then type it in by hand so i understand everything but at the moment i will just put that one in"

Neutron2k said: "that was php. screw learning it, just copy the code and make it do what you need it to!"

Sharky said: "lol i want to learn it how els will i be able to remember it :P"

Neutron2k said: "by saving the code and using it again later? you cannot learn everything at once dude!"

Sharky said: "fair enough it has confused me just looking at it :p"

Neutron2k said: "i have that ability on everyone. sorry"