473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

PHP Web Form Script Problem

Hello,

I have written the following HTML Form:

<html><head><title>Survey</title></head>
<body bgcolor="black" text="white" link="#f6b580" vlink="#c0c0ff">
<img src="logo.gif" width="324" height="104"alt="logo.gif (15760
bytes)"><br><br>

<table border="0" cellpadding="0" cellspacing="0" width="307" align="left">
<tr>
<td background="tableback.gif" height="25"><p align="center"><big>Game
Submission</big><br></td>
</tr>
</table>

<tr>
<td>
<br><br><br>
<FORM METHOD="POST" ACTION="sendgamesub.php"
enctype="text/plain">

<b>Game Title</b>:<br> <INPUT TYPE="text" NAME="title" SIZE="35"><br><br>

<b>Game Master</b>:<br> <INPUT TYPE="text" NAME="game_master"
SIZE="35"><br><br>

<b>E-Mail</b>:<br> <INPUT TYPE="text" NAME="email" SIZE="35"><br><br>

<b>Game System</b>:<br> <INPUT TYPE="text" NAME="game_system"
size="35"><br><br>

Standard Rules <INPUT TYPE="radio" NAME="rules" VALUE="Standard_Rules">

Modified Rules <INPUT TYPE="radio" NAME="rules"
VALUE="Modified_Rules"><br><br>

<b>Game Type</b>:<br>
CCG <input type="radio" name="type" value="CCG"><br>
Miniatures <input type="radio" name="type" value="mini"><br>
RPG <input type="radio" name="type" value="rpg"><br>
LARP <input type="radio" name="type" value="larp"><br>
Board <input type="radio" name="type" value="board"><br><br>
<b>Maturity Rating</b>:<br>
PG <INPUT TYPE="radio" NAME="rating" VALUE="PG"><br>
AA <INPUT TYPE="radio" NAME="rating" VALUE="AA"> <br>
R <INPUT TYPE="radio" NAME="rating" VALUE="R"> <br><br>

<b>Number of Players</b>:<br> Minimum:<input type="text" name="minplayers"
size="2"> Maximum:<input type="text" name="maxplayers" size="2"><br><br>

<b>Game Description:</b><br>
What is your game about? What sort of characters are <br> available? Brief
synopsis of plot.
Limit to 5-6 sentences <br>
<TEXTAREA NAME="Game_Description" ROWS=6 COLS=35></TEXTAREA> <br><br>

<b>Anything else we should know about?:</b><br>
<TEXTAREA NAME="Additional_Info" ROWS=6 COLS=35></TEXTAREA> <br><br>

<INPUT TYPE="image" VALUE="Send" SRC="submit.gif" HEIGHT="33" WIDTH="159"
BORDER=0 ALT="picture button">

</td>
</tr>

<table border="0" width="307" align="left">
<tr>
<td align=center><br><br><h6> <a href="main.html">Home</a> | <a
href="location.html">Location</a> | <a href="games.html">Games</a> | <a
href="register.html">Register</a> | <a href="survey.html">Survey</a> | <a
href="contact.html">Contact</a>
</h6>
<h6> <br> </td>
</tr>
</table></div></body></FORM></html>
I have also written the following PHP script:

<?php
$to = my*****@uoguelph.ca;
$title = ($_POST['title']);
$game_master = ($_POST['game_master']);
$email = ($_POST['email']);
$game_system = ($_POST['game_system']);
$rules = ($_POST['rules']);
$type = ($_POST['type']);
$rating = ($_POST['rating']);
$minplayers = ($_POST['minplayers']);
$maxplayers = ($_POST['maxplayers']);
$Game_Description = ($_POST['Game_Description']);
$Additional_Info = ($_POST['Additional_Info']);
$sub = "Game Submission";
$headers .= "From: " .$game_master."<".$email.">\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$mes = "Title: ".$title."
Game Master: ".$game_master."
E-Mail: ".$email."
Game System: ".$game_system."
Rules: ".$rules."
Type: ".$type."
Rating: ".$rating."
Min. Players: ".$minplayers."
Max. Players: ".$maxplayers."
Game Description: ".$Game_Description."
Additional Info: ".$Additional_Info."";

mail($to, $sub, $mes, $headers);
?>

The script isn't working properly. It sends the email but there is no data
in the email. For instance it doesn't send the Game Master or the Rating.
I can't seem to see where the problem is coming from. Can somebody point
out the problem. From what I can tell there doesn't seem to be any syntax
errors. I am fairly new to PHP so I could be mistaken.

Regards,
Jeff
Jul 17 '05 #1
6 2330
Jeff Dunnett wrote:
Hello,

I have written the following HTML Form:

<html><head><title>Survey</title></head>
<body bgcolor="black" text="white" link="#f6b580" vlink="#c0c0ff">
<img src="logo.gif" width="324" height="104"alt="logo.gif (15760
bytes)"><br><br>

<table border="0" cellpadding="0" cellspacing="0" width="307" align="left">
<tr>
<td background="tableback.gif" height="25"><p align="center"><big>Game
Submission</big><br></td>
</tr>
</table>

<tr>
<td>
<br><br><br>
<FORM METHOD="POST" ACTION="sendgamesub.php"
enctype="text/plain">

<b>Game Title</b>:<br> <INPUT TYPE="text" NAME="title" SIZE="35"><br><br>

<b>Game Master</b>:<br> <INPUT TYPE="text" NAME="game_master"
SIZE="35"><br><br>

<b>E-Mail</b>:<br> <INPUT TYPE="text" NAME="email" SIZE="35"><br><br>

<b>Game System</b>:<br> <INPUT TYPE="text" NAME="game_system"
size="35"><br><br>

Standard Rules <INPUT TYPE="radio" NAME="rules" VALUE="Standard_Rules">

Modified Rules <INPUT TYPE="radio" NAME="rules"
VALUE="Modified_Rules"><br><br>

<b>Game Type</b>:<br>
CCG <input type="radio" name="type" value="CCG"><br>
Miniatures <input type="radio" name="type" value="mini"><br>
RPG <input type="radio" name="type" value="rpg"><br>
LARP <input type="radio" name="type" value="larp"><br>
Board <input type="radio" name="type" value="board"><br><br>
<b>Maturity Rating</b>:<br>
PG <INPUT TYPE="radio" NAME="rating" VALUE="PG"><br>
AA <INPUT TYPE="radio" NAME="rating" VALUE="AA"> <br>
R <INPUT TYPE="radio" NAME="rating" VALUE="R"> <br><br>

<b>Number of Players</b>:<br> Minimum:<input type="text" name="minplayers"
size="2"> Maximum:<input type="text" name="maxplayers" size="2"><br><br>

<b>Game Description:</b><br>
What is your game about? What sort of characters are <br> available? Brief
synopsis of plot.
Limit to 5-6 sentences <br>
<TEXTAREA NAME="Game_Description" ROWS=6 COLS=35></TEXTAREA> <br><br>

<b>Anything else we should know about?:</b><br>
<TEXTAREA NAME="Additional_Info" ROWS=6 COLS=35></TEXTAREA> <br><br>

<INPUT TYPE="image" VALUE="Send" SRC="submit.gif" HEIGHT="33" WIDTH="159"
BORDER=0 ALT="picture button">

</td>
</tr>

<table border="0" width="307" align="left">
<tr>
<td align=center><br><br><h6> <a href="main.html">Home</a> | <a
href="location.html">Location</a> | <a href="games.html">Games</a> | <a
href="register.html">Register</a> | <a href="survey.html">Survey</a> | <a
href="contact.html">Contact</a>
</h6>
<h6> <br> </td>
</tr>
</table></div></body></FORM></html>
I have also written the following PHP script:

<?php
$to = my*****@uoguelph.ca;
$title = ($_POST['title']);
$game_master = ($_POST['game_master']);
$email = ($_POST['email']);
$game_system = ($_POST['game_system']);
$rules = ($_POST['rules']);
$type = ($_POST['type']);
$rating = ($_POST['rating']);
$minplayers = ($_POST['minplayers']);
$maxplayers = ($_POST['maxplayers']);
$Game_Description = ($_POST['Game_Description']);
$Additional_Info = ($_POST['Additional_Info']);
$sub = "Game Submission";
$headers .= "From: " .$game_master."<".$email.">\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$mes = "Title: ".$title."
Game Master: ".$game_master."
E-Mail: ".$email."
Game System: ".$game_system."
Rules: ".$rules."
Type: ".$type."
Rating: ".$rating."
Min. Players: ".$minplayers."
Max. Players: ".$maxplayers."
Game Description: ".$Game_Description."
Additional Info: ".$Additional_Info."";

mail($to, $sub, $mes, $headers);
?>

The script isn't working properly. It sends the email but there is no data
in the email. For instance it doesn't send the Game Master or the Rating.
I can't seem to see where the problem is coming from. Can somebody point
out the problem. From what I can tell there doesn't seem to be any syntax
errors. I am fairly new to PHP so I could be mistaken.

Regards,
Jeff


Not that it has anything to do with the problem, but you should be
single-quoting the email address:

$to = 'my*****@uoguelph.ca';

In fact, with PHP 5, the script aborted with this error:

PHP Parse error: syntax error, unexpected '@' in
D:\\htdocs\\sendgamesub.php on line 2, referer: http://localhost/test.html
You don't need the parens around all these:

$var = $_POST[...];
As for the empty content, it started working for me when I dropped the
'enctype="text/plain"' from the <form ...> element.
You should consider using an HTML validator. Firefox was a Tidy
extensions that lists 15 warnings for the page as listed above.

NM

--
convert UPPERCASE NUMBER to a numeral to reply
Jul 17 '05 #2
NM,

Thank you very much for your help. My problems are solved.

Regards,
Jeff
Jul 17 '05 #3
I noticed that Message-ID: <11*************@corp.supernews.com> from
News Me contained the following:
You don't need the parens around all these:

$var = $_POST[...];


In fact he could have saved the bother of writing those lines at all
e.g.

$headers .= "From: " .$_POST['game_master']."<".$_POST['email'].">\n";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Geoff Berrow wrote:
I noticed that Message-ID: <11*************@corp.supernews.com> from
News Me contained the following:
You don't need the parens around all these:

$var = $_POST[...];


In fact he could have saved the bother of writing those lines at all
e.g.

$headers .= "From: " .$_POST['game_master']."<".$_POST['email'].">\n";


NO!!!

Never *ever* put unvalidated content into your email headers.

Suppose I posted some data to your site with "game_master" set to something
like this:

no****@nowhere.com%0ATo:%2*************@ilikespam. org%0ASubject:%20V14GR4...

Insecure scripts like yours make things really easy for spammers. Think
about it.

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #5
Geoff Berrow wrote:
$headers .= "From: " .$_POST['game_master']."<".$_POST['email'].">\n";


Ugly.

Better:
$headers .= "From: {$_POST[game_master]} <{$_POST[email]}>\n";

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Jul 17 '05 #6
I noticed that Message-ID:
<pa****************************@tobyinkster.co.u k> from Toby Inkster
contained the following:
$headers .= "From: " .$_POST['game_master']."<".$_POST['email'].">\n";


Ugly.

Better:
$headers .= "From: {$_POST[game_master]} <{$_POST[email]}>\n";


The OP had already used the concatenation operator and so was familiar
with it. When I am teaching PHP, I find my students struggle with
syntax. Reducing the amount of things to remember helps.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joe | last post by:
I have wrote a script to query my mysql database based up a name that is selected from an HTML list menu, the form action calls to my php script from my html doc, I have tested connectivity to the...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
1
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
6
by: Joop | last post by:
Hi all, I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-) So, here's my problem : I've created a table in my document, presenting a list of items, one can 'select' by clicking...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
4
by: SteveS | last post by:
Hello. This is a strange problem which does not make sense to me. I open a popup page with the following javascript code: function OpenDenyWindow(changeId) {...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.