Jump to content

PHP not working


cwissick

Recommended Posts

Hi everyone,

 

I'm a rookie in website building and scripting (for which I am trying to teach myself). I watched a tutorial online and am trying to create a form in Dreamweaver to email to a recipient. Unfortunately, I think my scripting may be wrong because when I upload everything to my site, it doesn't work at all. Here is a copy of what I've done:

<?php

/= Subject and Email Variables =/
$emailSubject = 'Order Received!';
$webMaster = '[email protected]';

/= Gathering Data Variables =/
$nameField = $_POST['name'];
$addressField = $_POST['address'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$quantityField = $_POST['quantity'];
$quantity2Field = $_POST['quantity'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Address: $address <br>
Phone: $phone <br>
Email: $email <br>
Quantity Rings: $quantity <br>
Quantity Flags: $quantity2 <br>
EOD;

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


/= Results rendered as html=/
$theResults = <<<EOD
<html>
<head>
<title> Don's Olympic Notes</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
body {
background-color: #F9F9F9;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
.style1 {
color: #000000;
font-family: Arial, Helvetica, sans-serif;
}
body,td,th {
color: #000000;
}
-->
</style>
</head>

<div>
 <div align="left" class="style1">Thank you for your interest! Your email will be answered shortly!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";

?>

 

I appreciate any and all help! Hopefully it can be salvaged. Thank you so much!

Link to comment
https://forums.phpfreaks.com/topic/111737-php-not-working/
Share on other sites

Fix:

 

<?php

//Subject and Email Variables //
   $emailSubject = 'Order Received!';
   $webMaster = '[email protected]';
   
//Gathering Data Variables //
   $nameField = $_POST['name'];
   $addressField = $_POST['address'];
   $phoneField = $_POST['phone'];
   $emailField = $_POST['email'];
   $quantityField = $_POST['quantity'];
   $quantity2Field = $_POST['quantity'];

   $body = <<<EOD


--------------------------------------------------------------------------------


Name: $name 

Address: $address 

Phone: $phone 

Email: $email 

Quantity Rings: $quantity 

Quantity Flags: $quantity2 

EOD;

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

// Results rendered as html//
   $theResults = <<<EOD
<html>
<head>
<title> Don's Olympic Notes</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
body {
   background-color: #F9F9F9;
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   font-style: normal;
   line-height: normal;
   font-weight: normal;
   color: #666666;
   text-decoration: none;
}
.style1 {
   color: #000000;
   font-family: Arial, Helvetica, sans-serif;
}
body,td,th {
   color: #000000;
}
-->
</style>
</head>

<div>
  <div align="left" class="style1">Thank you for your interest! Your email will be answered shortly!</div>
</div>
</body>
</html>

EOD;

echo $theResults;

?>

Link to comment
https://forums.phpfreaks.com/topic/111737-php-not-working/#findComment-573582
Share on other sites

Thank you for your help!

 

Everything is working when I upload the files to my site. After filling out the form and clicking submit, it continues to the "thank you" page, but in the email that is sent, none of the fields are actually filed out with what was entered (Name, Address, Phone, Email, Quantity, and Quantity2).

 

How do I fix this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/111737-php-not-working/#findComment-573612
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.