Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsDiscussion Forum → PHP4 Help
PHP4 Help
2004-03-05, 8:55 AM #1
OK, I have this problem where I have a form on the website, and scripted thorough PHP I'm sending any information submitted on that form to my e-mail address. The problem is all I'm getting is blank e-mails, with all the fields being blank. I could really use anyone's help. Here's the form:
http://kingcola.com/question.html
And here's the PHP4 script:
Code:
<?

mail("c.delsesto@cox.net", "King Beverage Questionaire Form", "Name: $name\nEstablishment:
 $establishment\nAddress: $address\nCity: $city\nState: $state\nZip: $zip\nPhone: $phone\nFax:
 $fax\nEmail: $email\nComments: $comment\n", "From: $name\nReply-To: $email\n");

?>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
   <title>king</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#999999">
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH="750" >
<tr>
<td COLSPAN="2" BGCOLOR="#000000"> 
<div align=right>
<br><b><i><font face="Verdana"><font color="#FFFFFF"><font size=+3>KING
Beverage Co.</font></font></font></i></b>
<br>
<hr ALIGN=RIGHT NOSHADE WIDTH="50%"></div>
</td>
</tr>

<tr>
<td VALIGN=TOP WIDTH="10%" BGCOLOR="#000000">
<div align=right><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="king.html">home</a></font></font></font></b>
<p><b><font face="Verdana"><font size=-1><a href="new.html">what's new</a></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="about.html">about</a></font></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="links.html">related
links</a></font></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="equip.html">service/equipment</a></font></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="productlist.html">product
list</a></font></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="troubleshoot.html">troubleshooting</a></font></font></font></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="specoffers.html">special
offers</a></font></font></font></b>
<p><b><i><font face="Verdana"><font color="#999999"><font size=-1>questionnaire</font></font></font></i></b>
<p><b><font face="Verdana"><font color="#FFFFFF"><font size=-1><a href="contact.html">contact</a></font></font></font></b></div>
</td>

<td>
<blockquote> 
<center><table BORDER COLS=1 WIDTH="80%" BGCOLOR="#FFCC99" >
<tr>
<td>
<center><font face="Verdana"><font size=+1>Answer these 5 questions to
see if </font></font>
<br><font face="Verdana"><font size=+1><b><i><u>KING COLA</u></i></b> is
right for you.</font></font>
<p><font face="Verdana">We guarantee to save you $500 - $5000+ per year.</font></center>
</td>
</tr>
</table></center>
<form method="post" action="formmail.php4">
<center><table BORDER=0 COLS=1 WIDTH="80%" >
<tr>
<td>
<center><table BORDER COLS=2 WIDTH="100%" >
<tr>
<td WIDTH="50%">
<dl><font face="Verdana"><b><font size=-1>1)</font></b><font size=-2> When
dining out, do you think you know the brand of soda you're drinking?</font></font></dl>

<blockquote><input type="radio" name="q1" value="No"><font face="Verdana"><font size=-2>A)
No</font></font>
<br><input type="radio" name="q1" value="Yes"><font face="Verdana"><font size=-2>B)
Yes</font></font></blockquote>
</td>

<td WIDTH="50%">
<dl><font face="Verdana"><b><font size=-1>2)</font></b><font size=-2> When
dining out, you order a Coke and they ask "Is Pepsi OK?". You...</font></font></dl>

<blockquote><input type="radio" name="q2" value="Pepsi"><font face="Verdana"><font size=-2>A)
have the Pepsi</font></font>
<br><input type="radio" name="q2" value="water"><font face="Verdana"><font size=-2>B)
have water</font></font></blockquote>
</td>
</tr>
</table></center>

<center><table BORDER COLS=2 WIDTH="100%" >
<tr>
<td WIDTH="50%">
<dl><font face="Verdana"><b><font size=-1>3)</font></b><font size=-2> I
believe customers choose to patronize a restaurant or bar for its... <font color="#FFFFFF">....</font></font></font></dl>

<blockquote><input type="radio" name="q3" value="food"><font face="Verdana"><font size=-2>A)
Food & service</font></font>
<br><input type="radio" name="q3" value="beverage"><font face="Verdana"><font size=-2>B)
Beverage brands</font></font></blockquote>
</td>

<td WIDTH="50%">
<dl><font face="Verdana"><b><font size=-1>4)</font></b><font size=-2> When
dining out, if a carbonated beverage is cold, fizzy, and tastes good, do
you care what brand it is?</font></font></dl>

<blockquote><input type="radio" name="q4" value="No"><font face="Verdana"><font size=-2>A)
No</font></font>
<br><input type="radio" name="q4" value="yes"><font face="Verdana"><font size=-2>B)
Yes</font></font></blockquote>
</td>
</tr>
</table></center>

<center><table BORDER COLS=1 WIDTH="50%" >
<tr>
<td><font face="Verdana"><b><font size=-1>5)</font></b><font size=-2> Do
you like <b><u>saving money</u></b> and <b><u>maximizing your profitability</u></b>?</font></font>
<blockquote><input type="radio" name="q5" value="Yes"><font face="Verdana"><font size=-2>A)
Yes</font></font>
<br><input type="radio" name="q5" value="No"><font face="Verdana"><font size=-2>B)
No</font></font></blockquote>
</td>
</tr>
</table></center>
</td>
</tr>
</table></center>

<p><font face="Verdana"><font size=-1>If you chose (<b>A</b> ) to any or
all of the questions above, then <b>KING COLA</b> is right for you. Make
a <b><i>profitable business decision</i></b> right now. Call or e-mail
us and join or growing list of satisfied customers. Let us show you how
we can save you loads of money while still serving quality beverages.</font></font>
<center>
<p><b><font face="Verdana"><font size=-1>Complete and submit the form below,
or call us TODAY!</font></font></b></center>

<hr WIDTH="100%">
<br> 
<center><table BORDER=0 COLS=2 WIDTH="90%" >
<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>Name:</font></font></div>
</td>

<td><input type="text" size="25" name="name"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>Establishment:</font></font></div>
</td>

<td><input type="text" size="30" name="establishment"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>Address:</font></font></div>
</td>

<td><input type="text" size = "25" name="address"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>City:</font></font></div>
</td>

<td><input type="text" size="15" name="city"><font face="Verdana"><font size=-1>State:<input type="text" size="2" value="RI" name="state">Zip
Code:</font></font><input type="text" size="4" name="zip"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>Phone:</font></font></div>
</td>

<td><input type="text" size="15" name="phone"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>FAX:</font></font></div>
</td>

<td><input type="text" size="15" name="fax"></td>
</tr>

<tr>
<td WIDTH="1%">
<div align=right><font face="Verdana"><font size=-1>E-mail:</font></font></div>
</td>

<td><input type="text" size="30" name="email"></td>
</tr>

<tr>
<td>
<div align=right><font face="Verdana"><font size=-1>Questions/Comments:</font></font></div>
</td>

<td><textarea name="comment" rows="5" cols="35"></textarea></td>
</tr>
</table></center>

<center>
<p><input type="submit" value="Send"> <input type="reset" value="Clear"></center>
</blockquote>
</td>
</tr>
</table></center>
</form>
</body>
</html>


[This message has been edited by JASRCC_Uber0010 (edited March 05, 2004).]
GOOGLE FIND THESE SITES PLEASE KTHXBYE
http://www.stevebcartoons.com
http://www.kingcola.com
2004-03-05, 9:01 AM #2
Post the whole script.

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-03-05, 9:02 AM #3
yes, post the whole thing. How are you sending the variables? It seems like they're not being set.

Edit: Forgot the obligatory comment about the tech forum [http://forums.massassi.net/html/tongue.gif]

------------------
WARNING: THIS POST MAY CONTAIN TRACES OF PEANUT!!!
---@%

[This message has been edited by TheJkWhoSaysNi (edited March 05, 2004).]
TheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWho
SaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTh
eJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSa
ysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJ
k
WhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSays
N
iTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkW
2004-03-05, 9:11 AM #4
Done.
GOOGLE FIND THESE SITES PLEASE KTHXBYE
http://www.stevebcartoons.com
http://www.kingcola.com
2004-03-05, 9:17 AM #5
The problem is... you have it sending the mail on every page load. Every time someone goes to that page it will send the variables.

------------------
WARNING: THIS POST MAY CONTAIN TRACES OF PEANUT!!!
---@%
TheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWho
SaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTh
eJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSa
ysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJ
k
WhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSays
N
iTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkW
2004-03-05, 9:22 AM #6
It would be easier if you had your To, Subject and Body set as variables.
Code:
$to = "c.delsesto@cox.net";
$subject = "King Beverage Questionaire Form";
$body = "Name: " . $name . "\nEstablishment:
" . $establishment . "\nAddress: " . $address . "\nCity: " . $city . "\nState: " . $state . "\nZip: " . $zip . "\nPhone: " . $phone . "\nFax: " . $fax . "\nEmail: " . $email . "\nComments: " . $comment . "\n";
$header = "From: " . $name . "\nReply-To: " . $email . "\n";

mail ($to, $subject, $body, $header);

Notice the concatenation between the text and variables.
Try that. It works for me.


------------------
To artificial life, all reality is virtual.
HTP
2004-03-05, 9:26 AM #7
Dude, you never defined your variables. Youve got to split out the POST data into the seperate variables. If you were using Perl, I could give you the code right here . . but your using PHP....

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-03-05, 9:29 AM #8
Quote:
<font face="Verdana, Arial" size="2">Originally posted by GBK:
Dude, you never defined your variables. Youve got to split out the POST data into the seperate variables. If you were using Perl, I could give you the code right here . . but your using PHP....

</font>


The form names are the variables, he doesnt need to.


------------------
WARNING: THIS POST MAY CONTAIN TRACES OF PEANUT!!!
---@%
TheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWho
SaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTh
eJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSa
ysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJ
k
WhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSays
N
iTheJkWhoSaysNiTheJkWhoSaysNiTheJkWhoSaysNiTheJkW
2004-03-05, 9:34 AM #9
The option of having the form names automatically turned into variables isnt always turned on by default in every php installation...

I've heard its more secure to have that option turned off actually.

------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...

DSettahr's Homepage
2004-03-05, 9:42 AM #10
WTF? PHP will automatically assign form values as variables? [http://forums.massassi.net/html/confused.gif]

------------------
The future is here, and all bets are off.
And when the moment is right, I'm gonna fly a kite.
2004-03-05, 9:49 AM #11
Of course, GBK. The point of PHP is to make web programming EASY. It sounds like register_globals is off, so a form element called "name" won't be $name, but rather, since the register_globals is off, you access it through the superglobals:

$_GET
$_POST

Whichever way your form is set up. For example:

$_GET['name']
$_POST['name']

------------------
EvilMagic.net: Brian's Web Log
2004-03-05, 10:40 AM #12
Quote:
<font face="Verdana, Arial" size="2">$_GET['name']
$_POST['name']</font>

So where would I put this exactly?
GOOGLE FIND THESE SITES PLEASE KTHXBYE
http://www.stevebcartoons.com
http://www.kingcola.com
2004-03-05, 11:06 AM #13
What I posted earlier except where I put the variables use $_POST[name] or $_GET[name].

From the looks of your form you will use $_POST[].

------------------
To artificial life, all reality is virtual.
HTP
2004-03-05, 11:16 AM #14
So for example replace $name w/ $_POST[name] & $city with $_POST[city]?

[This message has been edited by JASRCC_Uber0010 (edited March 05, 2004).]
GOOGLE FIND THESE SITES PLEASE KTHXBYE
http://www.stevebcartoons.com
http://www.kingcola.com
2004-03-05, 11:17 AM #15
Yes.


------------------
To artificial life, all reality is virtual.
HTP
2004-03-05, 11:19 AM #16
Bleh...
Don't forget your single quotes.
Sorry.
$_POST['name']


------------------
To artificial life, all reality is virtual.
HTP
2004-03-05, 11:21 AM #17
OK, only problem is now for examnple when I recieve an e-mail it says from "Chris.Del.Sesto@ogre.web.pas.earthlink.net" is there someway I could just make it display the name alone without the other garbage after that?

[This message has been edited by JASRCC_Uber0010 (edited March 05, 2004).]
GOOGLE FIND THESE SITES PLEASE KTHXBYE
http://www.stevebcartoons.com
http://www.kingcola.com
2004-03-05, 12:00 PM #18
Give this a quick read.
It isn't very long.
http://www.sitepoint.com/article/advanced-email-php/1

------------------
To artificial life, all reality is virtual.
HTP

↑ Up to the top!