Jump to content

email form problems.


snottrocket

Recommended Posts

So, I'm working on this contact form for a project. I found a tutorial on building such a form which turned out to be simple enough.  It seems to work as far as when I submit, the echo response shows up in the browser window..however, there's no actual email that shows up in my mailbox.

 

Here's the code for the form:

 

<form name="contact" id="contact" method="post" action="mailer.php">
  <p>
    <label for="fullname">Name:</label>
    <input type="text" name="name" class="txt">
  </p>
  <p>
    <label for="address"> Property Street Address:</label>
    <input type="text" name="address" class="txt">
  </p>
  <p>
    <label for="city">City:</label>
    <input type="text" name="city" class="txt">
  </p>
  <p>
    <label for="state">State:</label>
    <input type="text" name="state" class="txt">
  </p>
  <p>
    <label for="zip">Zip:</label>
    <input type="text" name="zip" class="txt">
  </p>
  <p>
    <label for="owners">Owner(s) of Record:</label>
    <input type="text" name="owner" class="txt">
  </p>
  <p>
    <label for="parcel">Parcel ID#

(Leave Blank if Unknown):</label>
    <input type="text" name="parcel" class="txt">
  </p>
  <p>
    <label for="phone">Phone:</label>
    <input type="text" name="phone" class="txt">
  </p>
  <p>
    <label for="email">Email:</label>
    <input type="text" name="email" class="txt">
  </p>
  <p>
    <label for="thanking">Who do we thank for referring you?</label>
    <input type="text" name="thanking" class="txt">
  </p>


  <p><strong>Ready to reduce your soaring property taxes? Then check off level of assistance.</strong></p>
  <p>
    <input type="radio"  value="yes"  name="option">
    Tool Box

    <input type="radio" value="no" name="option">
    Self Starter Kits 

    <input type="radio" value="no" name="option">
    Predetermination Analysis 

    <input type="radio" value="no" name="option">
    Consultation 

    <input type="radio" value="no" name="option">
    Other </p>
  <p> Message:

    <textarea rows="9" name="comment" cols="30"></textarea>
  </p>
  

<div id="subButton"> 
	<input class="buttons"  type="image"  src="images/formSubmit.gif" tabindex="3" name="submit" value="submit" />
</div>
</form>

 

Here's the code for the script:


<?php
if(isset($_POST['submit'])) {


$to = "xxxxxxx@goofyEmail.com"; 
$subject = "Service inquiry";
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$owner = $_POST['owner'];
$parcel = $_POST['parcel'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$thanking = $_POST['thanking'];

$comment = $_POST['comment'];
$option = $_POST['radio'];



$body = "From: $name\n

Address: $address\n

City: $city\n

State: $state\n

Zip: $zip\n

Owner: $owner\n

Parcel Number: $parcel\n

Phone Number: $phone\n

Referral Name: $thanking\n

E-Mail: $email\n

Option: $option\n

Message: $comment\n ";  

echo "Thank you! Your Wicked Awesome Service Inquiry has been submitted to $to!";
mail($to, $subject, $body, "From: $from");

} else {

echo "Oops. You have reached this page in error.";

}
?>

 

I also sent this to a friend for him to test on his server. Same results..form works but no email arrives.

 

now, someone gave me this code to try out in order to make sure it's not my server and is in fact my code:

<?php
    $mail_test = mail("youremail@yourdomain.com", "Test Email", "This is a test message...");
    if( $mail_test === true ) {
        echo "Sent email";
    } else {
        echo "Mail failed!";
    }
?>

 

tried the page...loaded it in my browser and it worked fine...but no email hit my inbox. :wtf:

 

So, I'm not sure if it's my code or my hosting. I have a flash - to - php form for my personal site that works fine so that would have me thinking it might be my hosting.  I tried moving this form and the script to a different location on the server thinking that might make a difference but it didn't. Also, again, I had a friend load it on their server as well...thinking it might be my server but the result is the same. So, I'm quite sure it's my code...but I'm just not sure where the issue is.

 

One other thing, I looked at another tutorial with the most basic form I could find...email address and message input, button...nothing more.  Same result. 

 

Not sure where to go from here. :confused:

 

Any help or input is appreciated.

Link to comment
Share on other sites

 

Just in case you havent checked this yet:

1. Check your junkfolder... Usually where email like this ends up in todays emailingsystems.

2. See if you webhost supports emails and if you need to specify any protocols when doing so. If its a free webhost most likely they wont support it.

3. Nothing to check, just a tip: Dont try to send emails via WAMP locally.. Its a mess.

 

There is nothing wrong with the code.. Just tested it out on my server and it worked.

Link to comment
Share on other sites

okay so it does work. you got an email response from the form?

 

So it's possible that my hosting service is trashing it before it does anything?  It's weird, like I mentioned before; my personal site is flash based and I have a contact form...php driven...and it works pretty good...though there are some issues, I'll address them in another thread.

 

OKay..well, I'll send it over to my partner and see if he can get it working with a different email address just in case there's a problem there.

 

I'll post what I find out.

 

Thanks so much.

Link to comment
Share on other sites

Update:

 

Form works great now. Thanks for all the help.

 

Hopefully one last question:  the form goes through and the email client displays the subject, body of the email but the from section lists as unknown sender or nobody.  We'd like to change that to read the email address of whomever sent the info

 

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


$to = "xxxxx@domain.com"; 
$subject = "subject of email!";
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$owner = $_POST['owner'];
$parcel = $_POST['parcel'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$thanking = $_POST['thanking'];

$comment = $_POST['comment'];
$checkOff = $_POST['checkOff'];



$body = "From: $name\n

Address: $address\n

City: $city\n

State: $state\n

Zip: $zip\n

Owner: $owner\n

Parcel Number: $parcel\n

Phone Number: $phone\n

Referral Name: $thanking\n

E-Mail: $email\n

Option: $checkOff\n

Message: $comment\n";  

echo "Thank you! Service Inquiry has been submitted to $to!";

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

} else {

echo "Oops. You have reached this page in error.";

}

 

using $email doesn't seem to work but I'm waiting to see if the server needs to update fully.

 

Any thoughts on this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.