i have registration form in which user has to put his ;
email :
name:
phone:
Altphone:
and select courses .
when he clicks submit control is passed to below php form . this has coded to validate each and every field and check if email belongs to spsu.edu domain , and if its of correct format.
and data is inserted in database.
there is some fault for email , values don't get inserted . if i just do $email=$_post['email'] then data is stored in database , but when i write function valid_email($email) , for checking user input ...i can't store user data into database..
please help!!! appreciate it !! in Advance..
Main Topics
Browse All Topics





by: cxrPosted on 2009-06-08 at 11:17:14ID: 24574821
The regexp is wrong, it does not accept all valid emails. See my answer in the related question for a better regexp.
>> want to insert email into database only if email is in correct format !!
Then put the INSERT statement within a if statement, like this:
if(valid_email($email)) {
mysql_query("INSERT INTO ...");
}
>> also i want validation like say only emails from @hotmail .com
Then you need another if condition. You can do like this:
if(valid_email($email)) {
list($name,$domain) = explode('@',$email);
if($domain == 'hotmail.com') {
mysql_query("INSERT INTO ...");
}
}