if not empty check for common character
Well the subject pretty much explains what it is that I am looking for. I need a simple code snippet that will check the email field if it is not empty.
Of course if I went checked the empty field for "@" it obviously wouldn't find it and would give the user an error. But if they don't have email...they don't have email. But I want to make sure that they type it in correctly. This is my best guess...
if ($email == $_) {
if ($email =~ m/@/) {
$status = "valid";
} else {
$status = "not";
}
} else {
$status = "valid";
}
of course this code is ugly and probably won't work. So if someone could give me some insight on a better way to evaluate the email field I would be thankful.
Thanks for your help.
VulKen
Man who drive like hell, bound to get there!
Pimpin like a pimp with an electrofied pimpin machine!
Laguna Loire posted this at 15:45 — 10th August 2000.
They have: 45 posts
Joined: Aug 2000
is someone else could help me!
if ($email eq "") {
$status ="Valid";
} else {
if ($email =~ m/\@/) {
$status = "valid";
} else {
$status = "not";
}
}
I *think* that will work
Laguna Loire
Site Director: Laguna's Jukebox (http://jukebox.3dstream.net)
Site Admin: RPGBoards (http://rpgboards.3dstream.net)
richjb posted this at 18:30 — 10th August 2000.
They have: 193 posts
Joined: Feb 2000
This code has been tested:
if ($email ne "" && $email !~ /.*\@.*\..*/) {
print "invalid email format";
exit;
}
print "else";
Also, Laguna has the right idea...
Richard
[email protected]
Everyone here has a website. It's just that not all are worth posting (Mine! ).
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.