Skip to main content
Participant
July 14, 2009
Question

Php form script assistance

  • July 14, 2009
  • 1 reply
  • 4055 views

Hello please forgive me as I am new to this but really need assistance. I have a form created in html on a site and have tried numerous tutorials on creating a php script which would be linked to this html form, but each one I try either doesn't work or it seems as if it goes through but then I never recieve the mail in my mailbox. I used my yahoo account as well as another account and didn't get anything , can anyone please assist as to what I should do here is what I have so far.

Thank you in advance for any assistance provided.

HTML:

<form name="contactform" method="post" action="mailer.php">

         Name          <input type="text" name="name"/><br/><br/>

         Email          <input type="text" name="email"/><br/><br/>

         Address      <input type="text" name="address"/><br/><br/>

         City            <input type="text" name="city"/><br/><br/>

         When to Contact <select name="dropdown">

                           <option value="Morning">Morning</option>

                           <option value="Afternoon">Afternooon</option>

                           <option value="Evening">Evening</option>

                           </select><br/><br/>

         Purpose of Contact <br/><textarea name="commment" rows="6" cols="40">

        </textarea><br/> <br/><input type="submit" value="Submit Form Now" name="submit"/>

        </form>

Here is the script that I am using :

<?php

if(isset($_POST['submit'])) {

$to = "john@yahoo.com";

$subject = "Inquiry Form";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$address_field = $_POST['address'];

$city_field = $_POST['city'];

$comment= $_POST['comment'];

$dropdown = $_POST['dropdown'];

foreach($_POST['check'] as $value) {

$check_msg .= "Checked: $value\n";

}

$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";

echo "Data has been submitted to $to!";

mail($to, $subject, $body);

} else {

echo "Form not Submitted!";

}

?>

This topic has been closed for replies.

1 reply

DwFAQ
Participating Frequently
July 15, 2009

Have you confirmed that php is running on your server?

JUNKHEDAuthor
Participant
July 15, 2009

Hello thank you for responding... yes I believe it is , I have used a drag and drop flash component with a php script for another project I had worked on not too long ago and it worked fine. Im pretty sure it is running.

Does the code and script that I provided look correct to you?