Jump to content

Basic PHP script Im getting somthing wrong please help


Alesha

Recommended Posts

hi guys

 

i have been building a website and have added a contact form and PHP script to send me a email server side the script works as it it will refresh the pages and display my thank you message but no email ever turns up my email address is correct so there must be somthing else not working

 

<?php

/*Email Varibles*/

$emailSubject = 'media-ondemand-contact.php';
$webMaster = 'alextrashacc@hotmail.com';

/*Data Varibles*/

$email = $_POST['email'];
$name = $_POST['name'];
$radiobuttons = $_POST['radiobuttons'];
$where = $_POST['where'];
$comments = $_POST['comments'];
$newsletter = $_POST['newsletter'];

$body = <<<EOD
<br><hr><br>

Email: $email <br>
Name: $name <br>
Suggestions Ect: $radiobuttons <br>
Where did you hear about us: $where <br>
Comments: $comments <br>
News Letter Sign up: $newsletter

	$headers = "$email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);

EOD;
	$theResults = <<<EOD
<html>
<head>
<meta http-equiv="refresh" content="3;//media-ondemand.com">
<title>Sent Message</title>
<style type="text/css">
<!--
body {
text-align: center;
font-family: Verdana, Geneva, sans-serif;
font-size: 36px;
font-weight: bold;
font-variant: normal;
color: #666;
}
-->
</style>
</head>

<body>

<p>Thank You</p>
<p> Your Message Has Been Sent </p>
</body>
</html>
EOD;
echo "$theResults";
?>

 

the contact page is at www.media-ondemand.com/contact.html

Link to comment
Share on other sites

You can assign variables in a heredoc statement.

 

<?php
$subject 	      = 'media-ondemand-contact.php';
$web_master = 'alextrashacc@hotmail.com';

$email           = trim($_POST['email']);
$name  	     = trim($_POST['name']);
$radio 	     = trim($_POST['radiobuttons']);
$where 	     = trim($_POST['where']);
$comments    = trim($_POST['comments']);
$newsletter    = trim($_POST['newsletter']);

$body = <<<EOD
<br /><hr /><br />
E-mail: $email <br />
Name: $name <br />
Suggestions Etc: $radiobuttons <br />
Where did you hear about us: $where <br />
Comments: $comments <br />
Newsletter Sign-up: $newsletter
EOD;

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

$success = <<<EOD
<html>
<head>
<meta http-equiv="refresh" content="3;//media-ondemand.com">
<title>Sent Message</title>
<style type="text/css">
<!--
body {
text-align: center;
font-family: Verdana, Geneva, sans-serif;
font-size: 36px;
font-weight: bold;
font-variant: normal;
color: #666;
}
-->
</style>
</head>

<body>

<p>Thank You</p>
<p> Your Message Has Been Sent </p>
</body>
</html>
EOD;

if (mail($web_master, $subject, $body, $headers) !== FALSE) {
echo $success;
}
?>

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.