/    Sign up×
Community /Pin to ProfileBookmark

"ereg" problem in Contact Form

i added this contact form to my site [URL=http://latinsoldiers.com/socom3/contact.html] PREVIEW[/URL] where it says “Your Topic” it used to be ur “phone number” but everytime someone wants to send an email it gives them an erros saying that the phone info is invalid, since it was originally for phone number i think it doesnt accept letters only numbers. anyways this is the code for that part of the section i think.

[code=php]// check phone for validity
if (($PHONE_NO) || ($phone_no)) {
$phone_no = trim($phone_no);
if ($PHONE_NO)
$phone_no = trim($PHONE_NO);
if (!ereg(“(^[a-z]$)”, $phone_no)) {
print_error(“your <b>phone number</b> is invalid”);[/code]

i tried to fix it but couldnt, i put

[code=php](“(^[a-z]$)”, [/code]

but now it only lets me type lower case “a” in that section

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@purefanDec 12.2005 — I found this:
[code=php]
<?php
$email="[email protected]";

if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-
]+)*(.[a-z]{2,3})$", $email) {

echo "The e-mail was not valid";

} else {

echo "The e-mail was valid";

}

?> [/code]

here:http://www.zend.com/zend/spotlight/ev12apr.php

which is a tutorial on email validation

hope it helps

edit: btw cool site! love the flash menu and logo! :p
Copy linkTweet thisAlerts:
@DYABLOauthorDec 12.2005 — right next to the "eregi" what can i change so people can type anything in there and not necessary an email, i think something about erasing the "@" not sure tho.

thanks for the help.

[code=php]if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9- [/code]
Copy linkTweet thisAlerts:
@SpectreReturnsDec 12.2005 — If it doesn't need to be an email why do you need to validate it? ?
×

Success!

Help @DYABLO spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...