Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Php contact form help

  1. #11
    Join Date
    Sep 2013
    Location
    Antalya - Turkey
    Posts
    37
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    Of course. That's the example code I pointed out in my prior post.

    PHP Code:
    // inside your foreach loop

        // to check a specific field, check for the field name inside your loop.
        // this, for example, checks the "name" field specifically to see if its value is empty.
        
    if( $name === "name" && empty( $value )){
            
    $errors[$name] = "Please write your name!";
        }

        
    // do the same for "email", "verify", etc. 

    If i add this code,shall i delete some code from orginal php code ?

  2. #12
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    It depends on what you want your script to do. For example, by looping through each field, the current code allows you to check that all three fields are filled out without actually having to write that code three times. If you're going to check each field individually anyway, then you might get rid of the loop. On the other hand, if you don't want to check anything special (you just want special error messages), then you might as well leave the code inside the loop and just have a list of pre-defined messages for each field.

    So, what do you want to do? Start by listing each field on your form, and then deciding what errors you want to check for, and what messages to use in each case. Then, we can look at how best to organize them.

Similar Threads

  1. Contact form
    By jan24 in forum PHP
    Replies: 7
    Last Post: 10-11-2010, 06:48 PM
  2. Contact form
    By andyg41 in forum PHP
    Replies: 3
    Last Post: 08-02-2009, 08:47 PM
  3. Help with contact form please
    By cbleep in forum HTML
    Replies: 6
    Last Post: 09-14-2007, 07:12 PM
  4. Need a contact form....
    By k3v1n in forum Looking for such a script or service
    Replies: 10
    Last Post: 05-13-2007, 01:58 AM
  5. Contact Form
    By Johnnymushio in forum HTML
    Replies: 2
    Last Post: 08-25-2006, 05:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •