473,671 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Web Form Script Problem

Hello,

I have written the following HTML Form:

<html><head><ti tle>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="tab leback.gif" height="25"><p align="center"> <big>Game
Submission</big><br></td>
</tr>
</table>

<tr>
<td>
<br><br><br>
<FORM METHOD="POST" ACTION="sendgam esub.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_mast er"
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_syst em"
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"><b r>
RPG <input type="radio" name="type" value="rpg"><br >
LARP <input type="radio" name="type" value="larp"><b r>
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="minplayer s"
size="2"> Maximum:<input type="text" name="maxplayer s" size="2"><br><b r>

<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_Desc ription" ROWS=6 COLS=35></TEXTAREA> <br><br>

<b>Anything else we should know about?:</b><br>
<TEXTAREA NAME="Additiona l_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><b r><br><h6> <a href="main.html ">Home</a> | <a
href="location. html">Location</a> | <a href="games.htm l">Games</a> | <a
href="register. html">Register</a> | <a href="survey.ht ml">Survey</a> | <a
href="contact.h tml">Contact</a>
</h6>
<h6> <br> </td>
</tr>
</table></div></body></FORM></html>
I have also written the following PHP script:

<?php
$to = my*****@uoguelp h.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_Descripti on = ($_POST['Game_Descripti on']);
$Additional_Inf o = ($_POST['Additional_Inf o']);
$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: ".$minplaye rs."
Max. Players: ".$maxplaye rs."
Game Description: ".$Game_Descrip tion."
Additional Info: ".$Additional_I nfo."";

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 2344
Jeff Dunnett wrote:
Hello,

I have written the following HTML Form:

<html><head><ti tle>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="tab leback.gif" height="25"><p align="center"> <big>Game
Submission</big><br></td>
</tr>
</table>

<tr>
<td>
<br><br><br>
<FORM METHOD="POST" ACTION="sendgam esub.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_mast er"
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_syst em"
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"><b r>
RPG <input type="radio" name="type" value="rpg"><br >
LARP <input type="radio" name="type" value="larp"><b r>
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="minplayer s"
size="2"> Maximum:<input type="text" name="maxplayer s" size="2"><br><b r>

<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_Desc ription" ROWS=6 COLS=35></TEXTAREA> <br><br>

<b>Anything else we should know about?:</b><br>
<TEXTAREA NAME="Additiona l_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><b r><br><h6> <a href="main.html ">Home</a> | <a
href="location. html">Location</a> | <a href="games.htm l">Games</a> | <a
href="register. html">Register</a> | <a href="survey.ht ml">Survey</a> | <a
href="contact.h tml">Contact</a>
</h6>
<h6> <br> </td>
</tr>
</table></div></body></FORM></html>
I have also written the following PHP script:

<?php
$to = my*****@uoguelp h.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_Descripti on = ($_POST['Game_Descripti on']);
$Additional_Inf o = ($_POST['Additional_Inf o']);
$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: ".$minplaye rs."
Max. Players: ".$maxplaye rs."
Game Description: ".$Game_Descrip tion."
Additional Info: ".$Additional_I nfo."";

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*****@uoguel ph.ca';

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

PHP Parse error: syntax error, unexpected '@' in
D:\\htdocs\\sen dgamesub.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.supernew s.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.supernew s.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_maste r" set to something
like this:

no****@nowhere. com%0ATo:%2**** **...like spam.org%0ASubject:%20V 14GR4...

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.c o.uk> 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
1975
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 databse and have added a manual sql query to my php script to be sure it is functioning properly, the problem is I'm not sure how to get the script to see what option the html form is sending, I thought I could use: $query = "SELECT * FROM...
13
40721
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 style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
1
6011
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 required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
6
4037
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 on it... (Kinda like a menu, you make your choice from) But since this table can get very long, I've put something of a 'search-form' on top, which enables the user to make a
0
1881
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 have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source code. All the guts are in this first base class, and it doesn't do much. The rest is trivial...
4
3001
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) { retVal=window.showModalDialog('DenialEmailForm.aspx?id=1234'', 'dialogWidth:650px; dialogHeight:700px; resizable:no;'); //alert("Return val = " + retVal) }
25
4055
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
2115
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. Using Safari,my first iteration the script works fine ( indicating that there are 33 form variables ). When trying another dropdown select value, the
1
2543
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 everything was fine, so i changed the variable names (the names of the form elements, and the names of the rows in access) so that it would be more correct to what i am using it for. Now once I did that, it gave me an error on line 24 which was the...
0
3378
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 within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
0
8402
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8825
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8676
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.