php contact form inside of an email blast

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
uphamg
Forum Newbie
Posts: 3
Joined: Sun Feb 20, 2011 12:58 pm

php contact form inside of an email blast

Post by uphamg »

Hey guys, new to php and very new to this forum but I'm looking for some help. I am trying to create a contact form inside of an email blast that I am going to be sending out. I have created my html page and have it ready to go through yesmail direct. The script that I have now for the form works great when viewed on my actual html page. The problem is when I upload it through the email, it doesnt work or send anything. There is an else statement that is on the script that basically is I guess for when the person hits submit but they didnt actually hit submit from the html page like the case of hitting submit through your email client. I just dont understand what part of the script I need to change for the script to work from your email as well. Could anybody look at this and see if they know where the problem is please? Basically the only difference between hitting submit through the html page is you recieve the "Data has been submitted to..." output and just straight from the email you get the elses "blarg" output. I would be fine with that I would just change the literature on the "blarg" part but when you get the "blarg" one, the information is not sent to my email like I want it to. PLEASE HELP!!! Thank you in advance.



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

$to = "garyupham@gmail.com";
$subject = "How to Contact Me";
$number_field = $_POST['number'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$option = $_POST['radio'];
$facebook_field =$_POST['facebook'];
$twitter_field =$_POST['twitter'];


$body = "$check_msg How to best contact me: $option\n Phone Number: $number_field\n Facebook Address: $facebook_field\n Twitter Account: $twitter_field";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "blarg!";


}
?>
lunarnet76
Forum Commoner
Posts: 67
Joined: Sun Apr 04, 2010 2:07 pm
Location: Edinburgh

Re: php contact form inside of an email blast

Post by lunarnet76 »

hi,
Are you using a local webserver ?
Have you tried the function directly like

Code: Select all

<?php
mail('me@gmail.com','this is a test email','test');
?>
uphamg
Forum Newbie
Posts: 3
Joined: Sun Feb 20, 2011 12:58 pm

Re: php contact form inside of an email blast

Post by uphamg »

Not sure that I understand. I have that code that you see there in a file called mailer.php on my websites server and then in the html for the email blast I just have the form call that mailer.php file on my server? Does that make sense, not sure?
lunarnet76
Forum Commoner
Posts: 67
Joined: Sun Apr 04, 2010 2:07 pm
Location: Edinburgh

Re: php contact form inside of an email blast

Post by lunarnet76 »

well actually just tried in an empty file to put just
<?php
if(mail('me@gmail.com','this is a test email','test'))echo 'ok it has been sent';
?>
and see if it actually sends an email
uphamg
Forum Newbie
Posts: 3
Joined: Sun Feb 20, 2011 12:58 pm

Re: php contact form inside of an email blast

Post by uphamg »

In the tutorial http://www.kirupa.com/web/php_contact_form.htm
He says this...
In this section of code, I check to see if the visitor accessed mailer.php via contact.htm or if the visitor simply went to the mailer.php file directly. If the user pressed the Submit button on contact.htm, the if statement will return a true because isset($_POST['submit']) will not return false!

If someone accessed the site without first pressing the Submit button on contact.htm, isset($_POST['submit']) will return false and the code under else would be executed.
I think that this is where my problem is somewhere in here but I don't know how to fix it.
Post Reply