Current location: Hot Scripts Forums » Programming Languages » PHP » Help With Contact form Script


Help With Contact form Script

Reply
  #1 (permalink)  
Old 05-25-06, 02:54 PM
amorfgr amorfgr is offline
New Member
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Help With Contact form Script

I have a contact form script up and running. Thanks to karlcore's script it's very easy to do such a thing/But i have a small problem..
When i complete an email at the format name@in.gr or name@mail.gr or name@gmail.com it says tha the mail adress is wrong i think it's something in the script..so if anyone is so kind to help me with this problem..Cause the is plenty of ppl having mail adresses like name@mail.something .. or name@aa.aa
I am writing down the check mail part od the script..

PHP Code:

// ERROR & SECURITY CHECKS

    
if ( ( !$email ) ||
         ( 
strlen($_POST['email']) > 200 ) ||
         ( !
preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#"$email) )
       ) 
    { 
        print 
"Blad: Nie poprawny adres mailowy"
        exit; 
    } 
    if ( ( !
$name ) ||
         ( 
strlen($name) > 100 ) ||
         ( 
preg_match("/[:=@\<\>]/"$name) ) 
       )
    { 
        print 
"Blad: Nie poprawne Imie"
        exit; 
    } 
    if ( 
preg_match("#cc:#i"$message$matches) )
    { 
        print 
"Blad: Found Invalid Header Field"
        exit; 
    } 
    if ( !
$message )
    {
        print 
"Blad: Prosze wypelnic komentarz"
        exit; 
    } 
Don't know if it is corect to put this script here..if it is a problem so please delete the Post.
Many thnaks in advance for the help

Last edited by amorfgr; 05-25-06 at 03:04 PM.
Reply With Quote
  #2 (permalink)  
Old 05-25-06, 03:02 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
i think the problem is in the preg_match. but i'm not sure, i don't understand the errors, when you have one, you print on the screen

i don't think the # is a valid regex, you might wonna check on php.net for an easier, and more clearer preg_match for emails. here's an example:
PHP Code:

preg_match'/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i' $email
Greetz,
UnrealEd

PS: try posting your code wrapped in [PHP] tags
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 05-25-06, 03:06 PM
amorfgr amorfgr is offline
New Member
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
The error comes out when i user a mail with 2 characters after @ Example the form works ok if i use name@gmail.com but i gives me an error that the email is wrong when i use name@in.gr.. i can't get it..it's somewhere in preg_match which thinks that emails with 2 chars are wrong and not only..now i am trying and it says that anme@gmail.com is wrong can i make it more universal ?? so it'll allow ALL adresses ?? even 1@1.1 ?? no problem if the mail is wrong..i 'd rather have some stupid mails than none of them
Thanks UnrealEd for the quick reply

I tried yours
PHP Code:

preg_match'/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i' $email
But still the same..stupid errors :/

Last edited by amorfgr; 05-25-06 at 03:27 PM.
Reply With Quote
  #4 (permalink)  
Old 05-26-06, 05:22 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

preg_match('#^[a-z0-9]([_\.\-]?[a-z0-9]+)*@[a-z0-9]([\.\-]?[a-zA-Z0-9]+)*\.[a-z]{2,}$#i',  $string); 

matches #(valid char and -optional- atleast one valid char after each _.-)@(valid char and -optional- atleast on valid char after each .- ).(atleast two a-z)#case insensitive
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 2 01-02-06 11:55 PM
php form script to more then one email? burnttoast PHP 9 07-15-05 09:57 AM
contact form hazarus PHP 7 06-20-05 10:55 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
Php form validation script blessedrub PHP 4 10-16-04 07:15 PM


All times are GMT -5. The time now is 07:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.