1

Love the site, this is my first question here.. I'm new to programming php..I have the following coding on my default page where the Form is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mill City Cannabis</title>
</head>

<body bgcolor="#000000">
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
  <tr>
    <td>
        <center>
          <img src="Images/mccBanner.jpg" width="900" height="320" alt="Mill City Cannabis" />
        </center>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>
      <table width="1000">
        <tr>
          <td width="400">&nbsp;</td>
          <td>
            <form action="thankyou.php" name="feedback">
            <label>
              <font face="Tahoma" color="#00FF00" size="2">Name:</font>
            </label><br />
            <input type="text" name="name" style="font-size:10px font:Tahoma border-color:#0F0" required="required" /><br />
            <label>
              <font face="Tahoma" color="#00FF00" size="2">Email:</font>
            </label><br />
            <input type="email" name="email" required="required" /><br /><br />
            <label>
              <font face="Tahoma" color="#00FF00" size="2">What would you like to see as content here @ Mill City Cannabis:</font><br />
            </label>
            <textarea name="content" required="required"></textarea><br />
            <br />
            <input type="submit" name="submit" id="submit" value="Submit" />
            <input type="reset" name="reset" id="reset" value="Reset" />
            </form>
          </td>
          <td width="400">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

and when it renders to the "thankyou.php" page this is what's inside my "thankyou.php" page:

<?php

##############################
#                            #
# Coded By: Joshua Martinez  #
# MrJoshuaMartinez@gmail.com #
#                            #
##############################

/* Subject and Email variables */

$emailsubect = "Feedback";
$webMaster = "millcitycannabis@gmail.com";

/* Gathering Data Variables */

$namefield = $_POST['name'];
$emailfield = $_POST['email'];
$contentfield = $_POST['content'];

$body = <<<EOD
<br><hr><br>
Name: $namefield <br>
Email: $emailfield <br>
Feedback: $contentfield <br>
EOD;

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

/* Results rendered as HTML */

$theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mill City Cannabis</title>
</head>

<body bgcolor="#000000">
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="25">&nbsp;</td>
  </tr>
  <tr>
    <td>
    <center>
      <img src="Images/mccBanner.jpg" width="900" height="320" alt="Mill City Cannabis" />
    </center>
    </td>
  </tr>
  <tr>
    <td height="50">&nbsp;</td>
  </tr>
  <tr>
    <td align="center">
<font face="tahoma" size="2" color="#00FF00">
      Thank You For Your Feed Back!<br />
      Please check back soon with us!
    </font>
    </td>
  </tr>
  <tr>
<td align="center">
      <font face="tahoma" size="1" color="#00FF00">© All Rights Reserved</font> 
      <font face="tahoma" size="1" color="#FFFFFF">Mill City Cannabis </font>
      <font face="tahoma" size="1" color="#00ff00">2015</font>
</table>
</body>
</html>
EOD;
echo "$theResults";
?>

and finally when the email is sent, all that appears is:

Blank unknownk sender

Name: (blank)
Email: (blank)
Feedback: (blank)

2 Answers2

0
<form action="thankyou.php" name="feedback">

do mention method type here

<form action="thankyou.php" name="feedback" method="post">
habib ul haq
  • 824
  • 6
  • 13
  • ty ty can't believe how simple i over looked that – Joshua Martinez Apr 10 '15 at 05:04
  • that fixed the email problem for content inside the email. how ever it didn't fix the "Email from" part.. do I need to post a new question to get the answer to that? or is that something u could help me here? – Joshua Martinez Apr 10 '15 at 05:07
  • I still get unknown sender its a blank from in the email sender part.. thats what i mean no content there.. the email part fixed.. thanks – Joshua Martinez Apr 10 '15 at 05:10
  • what is the value of $email?? – habib ul haq Apr 10 '15 at 05:12
  • you didnt set $email to any value?? – habib ul haq Apr 10 '15 at 05:14
  • what do u mean the value of $email? I only have the value $emailfield there isn't $email that i can see.. i cpoy and pasted the entire two pages included every single letter.. what u see is everything.. – Joshua Martinez Apr 10 '15 at 05:15
  • I am talking about this part $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; where is this $email variable came from?? – habib ul haq Apr 10 '15 at 05:16
  • oh wow.. lol ur good.. totally missed that. It was suppose to be emailfield because thats who's email info was entered into the input field.. however now it seems that when i changed it to $emailfield\r\n it wont send any emails at all.. but when i switch it back.. it sends the email immediately however still as unknown sender – Joshua Martinez Apr 10 '15 at 05:22
  • did you enter a valid email. try this $headers="From:". $emailfield . "\r\n"; – habib ul haq Apr 10 '15 at 05:29
  • or try with some default email e.g $headers="From: abc@example.com"; – habib ul haq Apr 10 '15 at 05:31
  • when i did $headers = "From: abc@example.com\r\n"; it worked perfectly.. however when i did the first one u said still same issue it wont send if i add the variable $emailfield – Joshua Martinez Apr 10 '15 at 05:35
  • @JoshuaMartinez see this http://stackoverflow.com/questions/2014081/problem-with-php-mail-from-header – habib ul haq Apr 10 '15 at 05:47
  • @JoshuaMartinez you can use $headers .= "Reply-To:".$emailfield; if you try to reply the emai you sent, it will be a reply to your $emailfield.. – habib ul haq Apr 10 '15 at 06:09
  • thank you. Im just going to set it as "Feedback@millcitycannabis.com" because all I was looking for was to have the email sent to me as the email in the input field but you can't do that. so instead i made a generic email address so I know its feedback for my site. thank you so much for ur help! – Joshua Martinez Apr 10 '15 at 06:38
  • i did accept however i can't one up cause i dont have enough reputation – Joshua Martinez Apr 11 '15 at 07:12
0

You have not specified the form method.

By default form method is GET and in your php code you are trying to fetch the values from POST .

Bhavya Shaktawat
  • 2,504
  • 1
  • 13
  • 11
  • that fixed the email problem for content inside the email. how ever it didn't fix the "Email from" part.. do I need to post a new question to get the answer to that? or is that something u could help me here? – Joshua Martinez Apr 10 '15 at 05:07
  • you are using $email variable in from (header) which is not present in the code – Bhavya Shaktawat Apr 10 '15 at 05:13
  • yeah i noticed that someone else brought that to my attention.. it was meant to be $emailfield because email field is the email address the sender is using. However when I fix that in my code.. it doesnt send any emails now. so i tried it with $email it came unknown sender when i tried with $emailfield no email came and then i switched it back and a email came just unknown sender – Joshua Martinez Apr 10 '15 at 05:28