Page 1 of 1

sending email & text from html form to email address via

Posted: Tue Jul 18, 2006 12:56 pm
by kgrenier12
I created an .html form that uses "sendmail1.php" to send me an email with the information that the user enters. There are 11 fields that I want sent. I'm new to php and don't know what I'm doing wrong.

I'm receiving this error when I hit "submit"

Parse error: parse error, unexpected ',', expecting ']' in /web/virtual/iweb.bbn.com/htdocs/projects/publicize/sendmail1.php on line 3
*********************************
code from PHP sendmail1.php
<?
$email = $_REQUEST['email'] ;
$emailmessage = $_REQUEST['seriestype','seminardate','seminarlocation','seminartitle','description','speakername','speakerbio','speakerphoto'] ;


mail( "kgrenier@bbn.com", "SDP Seminar Iweb Online Request",
$emailmessage, "From: $email" );
header( "Location: thankyou.html" );
?>

**************************************
Code from html form:
<form method="post" action="sendmail1.php">
<table border="1" cellspacing="0">
<!--first row-->
<tr valign="top">
<td><font size="2">Your Name </font></td>
<td><font size="2"><input type="text" name="yourname" /></font></td>
</tr>
<tr valign="top">
<td><font size="2">Your Email </font></td>
<td><font size="2"><input type="text" name="email" size="15" /></font></td>
</tr>
<!--second row-->
<tr>
<td><font size="2">Type of SDP Seminar </font></td>
<td><select name="seriestype" size="1">
<option value=""></option>
<option value="Acoustic Technologies">Acoustic Technologies</option>
<option value="Agent Technology">Agent Technology</option>
<option value="Artificial Intelligence and Computer Games">Artificial Intelligence and Computer Games</option>
<option value="Distinguished Guest Lecturers">Distinguished Guest Lecturers</option>
<option value="Distributed Systems">Distributed Systems</option>
<option value="Education and Training">Education and Training</option>
<option value="High Performance Embedded Computing">High Performance Embedded Computing</option>
<option value="Information Security">Information Security</option>
<option value="Interface Usability">Interface Usability</option>
<option value="Math and Computation">Math and Computation</option>
<option value="Networking">Networking</option>
<option value="Physical Sciences">Physical Sciences</option>
<option value="Quantum Computing">Quantum Computing</option>
<option value="Robotics">Robotics</option>
<option value="Sensor Systems and Technologies">Sensor Systems and Technologies</option>
<option value="Software Development">Software Development</option>
<option value="Speech and Language Processing">Speech and Language Processing</option>
<option value="Women in Science and Technology">Women in Science and Technology</option>
</select>
</td>
</tr>

<tr valign="top">
<td><font size="2">Seminar Date</font></td>
<td><font size="2"><input type="text" name="seminardate" /></font> </td>
</tr>
<tr valign="top">
<td><font size="2">Seminar Time </font></td>
<td><font size="2"><input type="text" name="time" size="15" /></font></td>
</tr>

<tr valign="top">
<td width="68"><font size="2">Seminar Location</font></td>
<td><font size="2">
<input type="text" name="seminarlocation" />
</font></td>
</tr>
<tr valign="top">
<td width="68"><font size="2">Seminar Title:</font></td>
<td><font size="2">
<textarea name="seminartitle" cols="30"></textarea>
</font></td>
</tr>
<tr valign="top">
<td width="68"><font size="2">Seminar Description:</font></td>
<td><font size="2">
<textarea name="description" cols="30"></textarea>
</font></td>
</tr>
<tr valign="top">
<td width="68"><font size="2">Speaker Name:</font></td>
<td><font size="2">
<input type="text" name="speakername" />
</font></td>
</tr>
<tr valign="top">
<td><font size="2">Speaker Bio:</font>
<p></p></td>
<td><font size="2">
<textarea name="speakerbio" cols="30"></textarea>
</font></td>
</tr>
<tr>
<td><font size="2">Speaker Photo? (Y/N) </font></td>
<td><font face="Times New Roman, Times, serif">
<select name="speakerphoto" size="1">
<option value=""> </option>
<option value="Yes">Yes - please email it to communications@bbn.com</option>
<option value="No">No</option>
</select>
</font></td>
</tr>
</table>


<p>
<input name="submit" type="submit" value="Submit" />


</p>
</form>
*************************************

any help would be appreciated.

Posted: Tue Jul 18, 2006 2:04 pm
by RobertGonzalez
First recommendation, use the bbCode tags available to you. For html, you can use [ code ] or [ syntax="html" ]. For PHP, you can use [ php ] or [ syntax="php" ] (without the spaces - doing it the right way here would kill the bbcode I am using later).

As for your problem, you are killing your script with an incorrect use of the $_REQUEST array. You can't throw all the fields as the index to the $_REQUEST array and expect to get anything useful back from it (it's an array, so you can reference the array indeces one by one, or reference the entire array as an array).

What you are going to want to do is breakdown this:

Code: Select all

<?php
$email = $_REQUEST['email'] ;
$emailmessage = $_REQUEST['seriestype','seminardate','seminarlocation','seminartitle','description','speakername','speakerbio','speakerphoto'] ;
?>
into each of its individual parts...

Code: Select all

<?php
$email = $_POST['email'] ;
$seriestype = $_POST['seriestype'];
// Etc, etc for each passed form field.
?>
Then construct a message to send using these vars. Try it and see what you get. Also, search these forums for 'Sending Email' or 'Form Mail'. It might be useful.