Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi. I'm using xampp 1.8.0 with Windows 7 SP1, 32 bit OS, and coding HTML5 and CSS3. I'm just learning PHP, and I created a contact form for a dentist's Website, so that patients can request appointments. An email should go to the dentist and display the information that the user entered. (I only coded the 'name' and 'description' to be in the email so far, since this is just a test.) I'm using Javascript to check if the patient filled out the form properly, so I didn't use some of the code shown on pg. 332 of the book. There is an error on the first line: Parse error: syntax error, unexpected 'POST' (T_STRING), expecting ']'. Can someone tell me what's wrong? Thanks.

<?php

if ($_SERVER['REQUEST_METHOD] == 'POST'

{

body = "Name: ($POST['name']}\n\nComments: {$_POST['description']}";

 

$body = wordwrap($body, 70);

 

mail('mail@yahoo.com', 'Contact Form Submission', $body, "From: {$_POST['email']}");

 

echo 'Thank you for your request. A member of our staff will be contacting you shortly.';

 

$_POST = array();

}

 

?>

 

<div id="form">

<div id="contain">

 

<form action="EmailConf.php" method="post">

 

<table class="form_demo">

<tr>

<td>

<label>Name</label>

</td>

<td>

<input class="input_full" type="text" id="name" name="name" required="required" />

</td>

</tr>

<tr>

<td><label for="email">

Email

</label>

</td>

<td>

<input class="input_full" type="email" id="email" name="email" required="required" />

</td>

</tr>

<tr>

<td>

<label for="tel">

Phone

</label>

</td>

<td>

<input class="input_full" type="tel" id="tel" name="tel" required="required" />

</td>

</tr>

<tr>

<td><label for="priority_normal">

Priority

</label>

</td>

<td>

<input type="radio" name="priority" id="priority_urgent" value="Urgent">

<label for="priority_urgent">

Urgent

</label>

 

 

<input type="radio" name="priority" id="priority_normal" value="Normal" checked="checked">

<label for="priority_normal">

Normal

</label>

 

 

</td>

</tr>

<tr>

<td>

<label for="date">Enter a date:</label>

</td>

<td>

<input class="input_xlarge" type="text" id="date" name="date" required="required" />

 

<script>

(function($){

var pickerOpts = {

minDate: new Date(),

maxDate: "+3m,",

showButtonPanel: true,

showOn: "button",

 

buttonImage: "images/cal.png",

};

$("#date").datepicker(pickerOpts);

})(jQuery);

</script>

</td></tr>

<tr><td>Enter a time: </td>

<td><input id="time1" name="s2Time1" />

 

<script type="text/javascript">

$('#time1').ptTimeSelect({ popupImage: 'Select Time' });

</script>

</td>

</tr>

 

<tr>

<td>

<label for="description">

Reason for<br />

appointment

</label>

</td>

<td>

<textarea id="description" name="description" rows="3" required="required"></textarea>

</td>

</tr>

 

</table>

<hr />

<p class="clearfix">

<input type="submit" value="Submit" class="float_left" />

<input type="reset" value="Reset" class="float_right">

</p>

 

</form>
Link to comment
Share on other sites

if ($_SERVER['REQUEST_METHOD] == 'POST')

 

Replace first line with this.

 

Is a parse error on this line also

 

body = "Name: ($POST['name']}\n\nComments: {$_POST['description']}";

 

Replace with

 

body = "Name: ($_POST['name']}\n\nComments: {$_POST['description']}";

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...