...

View Full Version : Form Mailing



magius96
04-06-2004, 11:28 PM
I'm having a bit of a problem. I have an online application form that I'd like to have mailed to several people. I've made the form, and the form handler into one php file, and everything works wonderfully, except for one little thing. For some reason, it acts as if the user never typed anything into the form fields. Everything that I have hardcoded for the submission email is present, but all the stuff that's typed into the form, is missing.


<?php

foreach($_POST as $key => $value)
{
$$key = stripslashes($value);
}

if (isset($formstate)){
$subject = "Online Application for Immortality";
$address = "jasonyarber@hotmail.com, silaskashmir@yahoo.com, raynh@comcast.net, darkon@sbcglobal.net, tychrisbrown@yahoo.com";
$return = "From: $name<$email>";

$message = "Name: {$name}\nAge: {$age}\nCharacter: {$CharName}\nEmail: {$email}\nICQ: {$ICQ}\nAIM: {$AIM}\nYahoo: {$Yahoo}\nMSN: {$MSN}\nTime Played: {$TimePlayed}\nMUDs Played: {$NamePlayed}\nBuilt: {$Built}\nMUD Built: {$NameBuilt}\nOLC: {$OLC}\nPosition: {$Position}\nTime Availability: {$time}\nRead Handbook: {$policies}\n\nArea Name: {$AreaName}\nNumber of Rooms: {$NoRooms}\n\nArea Description: {$AreaDesc}\n\nRoom 1 Description: {$RoomDesc1}\n\nRoom 2 Description: {$RoomDesc2}\n\nRoom 3 Description: {$RoomDesc3}\n\nComments: {$Comments}";

mail($address, $subject, $message, $return);
ShowThanks();
} else {
ShowForm();
}

function ShowForm(){
print <<< ENDOFFORM
<html>
<body background="http://darkon.dyndns.org/mud/Darkon-back.jpg" text="#ffffff">

<h1><font size="4">Application for Immortality on Darkon </font></h1>

<form action="http://darkon.dyndns.org/mud/resources/application.php" method="POST" enctype="text/plain">
<p align="left"><font size="2"><br>
</font></p>
<table border="0">
<tbody>
<tr>
<td align="right" width="25%"><font size="1"><b>Name:</b></font></td>
<td width="25%"><font size="1"><input type="text" size="20" name="name"></font></td>
<td align="right" width="25%"><font size="1"><b>Age:</b></font></td>
<td width="25%"><font size="1"><input type="text" size="20" name="Age"></font></td>
</tr>
<tr>
<td align="right" width="25%"><font size="1"><b>Character
Name:</b></font></td>
<td width="25%"><font size="1"><input type="text"
size="20" name="CharName"></font></td>
<td align="right" width="25%"><font size="1"><b>E-mail:</b></font></td>
<td width="25%"><font size="1"><input type="text"
size="20" name="email"></font></td>
</tr>
<tr>
<td align="right" width="25%"><font size="1"><strong>ICQ:</strong></font></td>
<td width="25%"><font size="2"><input type="text"
size="20" name="ICQ"></font></td>
<td align="right" width="25%"><font size="2"><strong>AIM:</strong></font></td>
<td width="25%"><font size="2"><input type="text"
size="20" name="AIM"></font></td>
</tr>
<tr>
<td align="right" width="25%"><font size="2"><strong>Yahoo:</strong></font></td>
<td width="25%"><font size="2"><input type="text"
size="20" name="Yahoo"></font></td>
<td align="right" width="25%"><font size="2"><strong>MSN:</strong></font></td>
<td width="25%"><font size="2"><input type="text"
size="20" name="MSN"></font></td>
</tr>

</tbody>
</table>

<hr>
<h2><font size="3"><b>Previous Experience</b></font></h2>

<table border="0">
<tbody>
<tr>
<td align="right" width="25%"><font size="1"><b>How
long have you played MUDs?</b></font></td>
<td width="50%">
<select name="TimePlayed" size="1">
<option>&lt;not selected&gt;</option>
<option>&lt; 1 year</option>
<option>1 year</option>
<option>2 years</option>
<option>3 years</option>
<option>4 years</option>
<option>5 years</option>
<option>&gt; 5 years</option>
</select>
</td>
</tr>
<tr>
<td align="right" width="25%"><font size="1"><b>Name
of MUDs played</b></font></td>
<td width="50%"><font size="1"><input type="text" size="20" name="NamePlayed"></font></td>
<input type="hidden" name="formstate" value="process">
</tr>
<tr>
<td align="right" width="25%"><font size="1"><b>Have
you built on a MUD before?</b></font></td>
<td width="50%">
<table border="0">
<tbody>
<tr>
<td width="10%"><font size="1"><input type="radio"
checked="checked" name="Built" value="yes">Yes</font></td>
<td width="50%"><font size="1"><input type="radio"
name="Built" value="no">No</font></td>
</tr>

</tbody>
</table>
</td>
</tr>
<tr>
<td align="right" width="25%"><font size="1"><b>If
yes, where?</b></font></td>
<td width="50%"><font size="1"><input type="text"
size="20" name="NameBuilt"></font></td>
</tr>

</tbody>
</table>

<table border="0">
<tbody>
<tr>
<td width="50%"><font size="1"><strong>Which forms of
OLC are you familiar with?<br>
Please select all applicable. To select multiple
entries hold ctrl while left-clicking the mouse on the selection.</strong></font></td>
<td width="50%">
<select name="OLC" multiple="multiple" size="3">
<option>Circle</option>
<option>Diku</option>
<option>Merc</option>
<option>ROM</option>
<option>Smaug</option>
<option>Other</option>
</select>
</td>
</tr>

</tbody>
</table>

<p>&nbsp;</p>

<table border="0">
<tbody>
<tr>
<td valign="top" width="50%"><font size="1"><strong>What
position are you interested in?<br>
Please select all applicable. To select multiple
entries hold ctrl while left-clicking the mouse on the selection.</strong></font></td>
<td width="50%">
<select name="Position" multiple="multiple" size="3">
<option>Avatar</option>
<option>Head Avatar</option>
<option>Social Builder</option>
<option>Head Social Builder</option>
<option>Builder</option>
<option>Head Builder</option>
<option>Assistant Implementer</option>
<option>Implementer</option>
<option>Head Implementer</option>
<option>All</option>
</select>
</td>
</tr>

</tbody>
</table>

<hr>
<h2><font size="3"><b>Requirements</b></font></h2>

<p>&nbsp;</p>

<p><font size="1"><b>Can you log on for up to 2 hours every week and
do up to 30 minutes of work during that time?</b></font></p>

<table border="0">
<tbody>
<tr>
<td width="50%"><font size="1"><input type="radio"
name="time" value="Yes">Yes</font></td>
<td width="50%"><font size="1"><input type="radio"
name="time" value="No">No</font></td>
</tr>

</tbody>
</table>

<p><font size="1"><strong>Have you read and agree to the handbook regarding
being an immortal?</strong></font></p>

<table border="0">
<tbody>
<tr>
<td width="50%"><font size="1"><input type="radio"
name="policies" value="Yes">Yes</font></td>
<td width="50%"><font size="1"><input type="radio"
name="policies" value="No">No</font></td>
</tr>

</tbody>
</table>

<hr>
<h2><font size="3"><b>Area info</b></font></h2>

<table border="0">
<tbody>
<tr>
<td align="right" width="50%"><font size="1"><b>Name
of Area</b></font></td>
<td width="50%"><font size="1"><input type="text"
size="20" name="AreaName"></font></td>
</tr>
<tr>
<td align="right" width="50%"><font size="1"><b>How
many rooms?</b></font></td>
<td width="50%"><font size="1"><input type="text"
size="20" name="NoRooms"></font></td>
</tr>

</tbody>
</table>

<p><font size="1"><b>Description of Area</b><br>
<textarea name="AreaDesc" rows="5" cols="80" wrap=""></textarea></font></p>

<p><font size="1"><b>Please give us three example room descriptions.</b><br>
<textarea name="RoomDesc1" rows="5" cols="80" wrap=""></textarea><br>
<textarea name="RoomDesc2" rows="5" cols="80" wrap=""></textarea><br>
<textarea name="RoomDesc3" rows="5" cols="80" wrap=""></textarea></font></p>

<hr>
<p><font size="1"><b>Additional Comments:</b><br>
<textarea name="Comments" rows="5" cols="80" wrap=""></textarea></font></p>

<hr>
<p><font size="1">Please check to make sure you entered all the correct
infomation before you submit.<br>
</font><font size="2"><br>
<input type="submit" value="Submit" onsubmit="thankyou.html"> </font></p>
</form>

<p align="right"><font size="1">Copyright &copy; 2004 Darkon.dyndns.org</font></p>
<br>

</body>
</html>
ENDOFFORM;
}

function ShowThanks(){
print <<< ENDOFTHANKS
<html>
<body background = "http://darkon.dyndns.org/mud/Darkon-back.jpg" text="#ffffff">
<h1>Thank you</h1>
Thank you for your interest in joining our staff. Your application will be reviewed, and we will contact you soon.
</body>
</html>
ENDOFTHANKS;
}
?>

Nightfire
04-06-2004, 11:33 PM
Didn't look at the code, are you using the super globals? $_GET or $_POST? If not, then you should be using one of those two depending on the method of your form. Example


<?php
// form method is done via post
echo $_POST['formfieldname'];
// form method is done via get
echo $_GET['formfieldname'];
?>

<edit>See you edited your post as I was replying</edit>

magius96
04-06-2004, 11:34 PM
Super globals in the first 5 lines....or should I actually do each form field individually instead of using a general foreach()?

dswimboy
04-06-2004, 11:59 PM
personally, using variable references gets kinda scary. in theory, i think what you have should work, but i would still use $name = $_POST['name']; etc.

Nightfire
04-07-2004, 08:44 PM
Instead of the foreach loop, I'd just use


extract($_POST);

to replace it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum