Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Help with form

  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Help with form

    Hi, I need help with my contact form. It is not working for some reason. Kinda new to PHP so help would be appreciated.

    HTML SNIPPET

    Code:
    <form action="contact.php" method="post" id="contactform">
              <ol>
                <li>
                  <label for="name">Full Name</label>
                  <input id="name" name="name" class="text" />
                </li>
                <li>
                  <label for="email"> Email Address</label>
                  <input id="email" name="email" class="text" />
                </li>
                <li>
                  <label for="phone">Phone Number</label>
                  <input id="phone" name="company" class="text" />
                </li>
                <li>
                  <label for="company">Wedding Date</label>
                  <input id="company" name="company" class="text" />
                </li>
                <li>
                  <label for="subject">Subject</label>
                  <input id="subject" name="subject" class="text" />
                </li>
                <li>
                  <label for="street">Street Address</label>
                  <input id="street" name="subject" class="text" />
                </li>
                <li>
                  <label for="city">City</label>
                  <input id="city" name="subject" class="text" />
                </li>
                <li>
                  <label for="state">State</label>
                  <input id="state" name="subject" class="text" />
                </li>
                <li>
                  <label for="zip">Zip Code</label>
                  <input id="zip" name="subject" class="text" />
                </li>
                <li>
                  <label for="message">Message</label>
                  <textarea id="message" name="message" rows="4" cols="5"></textarea>
                </li>
                <li class="buttons">
                  <input type="image" name="imageField" id="imageField" src="images/send.gif" />
                </li>
              </ol>
            </form>
    PHP MAILER SNIPPET

    PHP Code:
    <?php

    if(!$_POST) exit;

    $email $_POST['email'];


    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
        
    $error.="Invalid email address entered";
        
    $errors=1;
    }
    if(
    $errors==1) echo $error;
    else{
        
    $values = array ('name','email','message');
        
    $required = array ('name','email','message');
         
        
    $your_email "nicksteig@steigdesign.com";
        
    $email_subject "Email from Contact Page: ".$_POST['subject'];
        
    $email_content "new message:\n";
        
        foreach(
    $values as $key => $value){
          if(
    in_array($value,$required)){
            if (
    $key != 'subject' && $key != 'company') {
              if( empty(
    $_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
            }
            
    $email_content .= $value.': '.$_POST[$value]."\n";
          }
        }
         
        if(@
    mail($your_email,$email_subject,$email_content)) {
            echo 
    'Message sent!'
        } else {
            echo 
    'ERROR!';
        }
    }
    ?>
    Last edited by steiger16; 05-23-2011 at 02:43 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    Please check out the [php] link in my signature.
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    steiger16 (05-23-2011)

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    sorry

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    No need to apologise, just read it and edit your post
    I can't really think of anything to write here now...

  • #5
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    better?

  • #6
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This code was taken from a template that I purchased and am trying to get it to work for my current needs.

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    Yes much better

    So what is the actual problem? - Does it not do anything? Is there an error message? - So far all you've done is say you got this as a template, shown the code and told us its not working for some 'reason'.

    If you can give us some better details we'll be able to help you further.
    I can't really think of anything to write here now...

  • #8
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    628
    Thanks
    51
    Thanked 67 Times in 67 Posts
    What are you trying to do and what about it isn't working?
    "Yeah science!"

  • #9
    New to the CF scene
    Join Date
    May 2011
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    when you fill out the form and click submit, it returns error. I even have it uploaded as a php page on my server. Not sure what is going on. This was a template but then I edited it just to add more fields in.

  • #10
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    628
    Thanks
    51
    Thanked 67 Times in 67 Posts
    Post the error, if you could.

    My assumption: All of your forms have the same name; the name should be unique (since the name is what is used to call the form data, e.g. $_POST['field1'] will contain the data for an input field named 'field1'.
    "Yeah science!"

  • Users who have thanked djh101 for this post:

    steiger16 (05-23-2011)


  •  

    Posting Permissions

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