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 01:43 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Please check out the [php] link in my signature.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • 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,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    No need to apologise, just read it and edit your post
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #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,313
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

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

  • #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
    616
    Thanks
    48
    Thanked 65 Times in 65 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!"
    Online Science Tools

  • 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
    •