Results 1 to 7 of 7

Thread: PHP: Simple Email Form

  1. #1

    PHP: Simple Email Form

    Hi, I have been trying to make a more difficult email that I still cannot get to work correctly I am now trying to make a more simple form but I still am not doing something right. Will someone please point out to me what I am doing wrong? or what needs to be chanegd?? Below is my html and php. PROBLEM: when you hit submit nothing happens it just clears my form completetly and does not email anything.

    Thank you!!!!
    rubberduckie

    HTML Code:
    <form method="POST" action="mailer.php"> 
              <label>First Name:
              <input type="text" name="first" id="first" />
              </label>
              <p><label>Last Name: 
                <input type="text" name="last" id="last" />
                </label>
              </p>
              <p>Class: 
                <label>
                <input type="radio" name="radio" id="2007" value="2007" />
                2007</label>
                     <label>
                <input type="radio" name="radio" id="2008" value="2008" />
                2008</label>
                     <label>
                <input type="radio" name="radio" id="2009" value="2009" />
                2009</label>
              </p>
    <p>
                      <label>Preferred E-mail: 
                      <input type="text" name="email" id="email" />
                      </label>
                    </p>
                    <p>Mailing
                      <label>Address: 
                      <input type="text" name="address" id="address" />
                      </label>
                      <label><br />
                      <br />
                      City:
                      <input type="text" name="city" id="city" />
                      </label>
                      <label>                  State:
                      <input type="text" name="state" id="state" />
                      </label>
     
                      <label>Zip:
                      <input type="text" name="zip" id="zip" />
                      </label>
                    </p>
                    <p>
                      <label>Current Residency or Internship Program & Speciality:
                      <input type="text" name="residency" id="residency" />
                      </label>
                    </p>
                    <p>
                      <label>Comments:
                      <input name="comments" type="text" id="comments" value="" size="45" />
                      </label>
                    </p>
                    <p>
                      <label>Any News; new residency, publications, awards, honors, weddings, engagements, births
                      <textarea name="news" id="news" cols="45" rows="5"></textarea>
                      </label>
                      <label></label>
                    </p>
              <p>
                <label>
                <input type="submit" name="submit" id="submit" value="Submit" />
                </label>
                <label>
                <input type="reset" name="reset" id="reset" value="Reset" />
                </label>
              </p>
            </form>
    PHP Code:
    <?php 
    if(isset($_POST['submit'])) { 
    $to "XXXX@myemail.com"
    $subject "Alumni Update"
    $firstname_field $_POST['first']; 
    $lastname_field $_POST['last'];
    $option $_POST['radio'];
    $email_field $_POST['email']; 
    $address_field $_POST['address']; 
    $city_field $_POST['city']; 
    $state_field $_POST['state']; 
    $zip_field $_POST['zip']; 
    $residency_field $_POST['residency'];
    $comments $_POST['comments'];
    $news $_POST['news'
     
    $body "From: $firstname_field\n $lastname_field\n Option: $option\n E-Mail: $email_field\n $check_msg  Address: $address_field\n City: $city_field\n state: $state_field\n Zip: $zip_field\n Residency:\n $residency_field\n Comments:\n $comments\n News:\n $news\n" 
     
    echo 
    "Thank you! Your information has been submitted to $to!"
    mail($to$subject$body); 
    } else { 
    echo 
    "blarg!"

    ?>
    Last edited by rubberduckie; September 22nd, 2009 at 10:16 AM.

  2. #2
    PHP Code:
    $news $_POST['news'
    should be:

    PHP Code:
    $news $_POST['news']; 
    add the semi colon at the end of the line.

    Your web server must not be configured to display PHP errors, which is why the page remained blank.

  3. #3
    And is that email address real? You should probably edit it out of your post unless you want loads of spam sent to it.

  4. #4
    Thank you very much for your help!!! and pointing out the email!!!! It works now!! Thanks!!

  5. #5
    No problem, you're welcome.

  6. #6
    I just have one more (probably simple) question.....after it submits the form it goes to a plain page that says "Thank you! Your information has been submitted to $to!" after this shows up is there an easy way to redirect it to another page? or have it direct to a page that has the message but using our website template?

  7. #7
    Ignore last message I have figured it out!! Thanks for your help!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012