Jump to content

E-mail form?


m0nk

Recommended Posts

Hello everyone,

 

First off I'd like to let you know that I am new to PHP and am just learning the basics at this point. what I've created is a simple php file that is supposed to send data from a web form and e-mail it to me, but unfortunately it's not sending me the e-mail with the data. When this happened I found a tutorial and entered the php text line by line with the guy in the tutorial but when i ran it, I still had the same issue of it not sending me an e-mail. I'll post my code below, but does anyone know why it might not be sending me the e-mail? In his tutorial it seemed to work perfectly but mine doesn't :(.  If anyone is curious what tutorial I found it was at

from tutvid. I've also tried sending it to three different e-mail addresses including yahoo, gmail, and my work e-mail so I know my syntax where I put in my e-mail was correct. Also, my webhost DOES support php so I don't think that's the issue either....and I have checked and double checked the names of my variables and they match the variables on my web form perfectly.... Any help would be GREATLY appreciated.

Here is the code...

 

<?php

 

/* Subject and Email Variablees */

 

$emailSubject = 'Crazy PHP Scripting!';

$webMaster = 'your@email.com';    /*edited out for the forum post*/

 

/* Gathering Data Variables */

 

$emailField = $_POST['email'];

$nameField = $_POST['name'];

$phoneField = $_POST['phone'];

$budgetField = $_POST['budget'];

$travelersField = $_POST['travelers'];

$commentsField = $_POST['comments'];

$newsletterField = $_POST['newsletter'];

 

$body = <<<EOD

<br><hr><br>

Email: $emailField <br>

Name: $nameField <br>

Phone Number: $phoneField <br>

Budget: $budgetField <br>

Number of Travelers: $travelersField <br>

Comments: $commentsField <br>

Newsletter: $newsletterField <br>

EOD;

 

$headers = "From: $emailField\r\n";

$headers .= "Content-type: text/html\r\n";

$success = mail($webMaster, $emailSubject, $body, $headers);

 

/* Results rendered as HTML */

 

$theResults = <<<EOD

<html>

<head>

<title>JakesWorks - travel made easy-Homepage</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

<!--

body {

background-color: #f1f1f1;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #666666;

text-decoration: none;

}

-->

</style>

</head>

 

<div>

  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>

</div>

</body>

</html>

EOD;

echo "$theResults";

 

 

 

?>

Link to comment
Share on other sites

can u put your code in tags please

 

are you recieving the emails at your other emails?

 

if you are then the problem is with your other email address.

 

Maybe your email host is flaggin the emails as spam or infected.

 

I've seen some do this before, they like to flag them if they are really small sizes. Don't know why

Link to comment
Share on other sites

Sure! I just registered today so I didn't know to do that...as soon as i figure it out I will for sure. Actually I'm not getting e-mails at any of the e-mail addresses that I specify, so I'm not sure what the issue is, especially since the code on the tutorial that the guy used worked fine and it's identical to mine. One thing that I noticed on one line is $success = mail() that goes directly into the mail() function. From previous programming experience I don't see anything calling the $success variable to initiate the function mail(), so when I troubleshooted it and I deleted the $success variable to just have the php program run mail(), it still didn't send the e-mail  ??? Man I'm completely stumped....

Link to comment
Share on other sites

I guess what I'm trying to ask is if there is something blatantly wrong with my code, or if in theory, after reviewing it, it should work?  And if so if you have any suggestions as to what might be the issue with it not sending me e-mails... :(

Link to comment
Share on other sites

I guess what I'm trying to ask is if there is something blatantly wrong with my code

 

Ok so I decided to test it a different way by on the bottom line having it say this

;EOD
echo "$body";

That way it outputs the the e-mail that I want it to send so I know if my code was working...it was a success, so my script is running fine, with the exception of the mail() function not working and thus not sending an e-mail out. Please, does anyone have any suggestions? As far as I can see my syntax for the mail() function is correct....

 

Thank you,

 

m0nk.

 

 

Link to comment
Share on other sites

Hey Elis thank you very much for taking the time out to test it!!!!!!!...and that is probably the best suggestion that I've heard so far (seriously). The problem is I am really new to php so I don't know how to enable the mail() function (which means it's most likely not enabled and you are right). So if you can point me in the right direction I would really appreciate it and if it works you would alleviate a ton of headaches for me.

 

-m0nk

Link to comment
Share on other sites

php doesn't "Debug" in a program... php is a server side scripting language that gets parsed through the php engine. Thus in order to "debug" it you must run the php file through the browser. If error reporting is turned on.. it would blatently tell you that "function mail() doesn't exist" blah blah and so forth.. again PHP and dreamweaver... not the best of friends.. seriously drop dreamweaver man.. learn to code for real.

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.