View Full Version : virgin PHP problems
wolverine74
June 22nd, 2006, 10:30 AM
I'm quite new to PHP and have downloaded a file from Kirupa... it's a PHP Contact form... it works like a dream... the problem is that I can't get it to work on a booking form that I created.. it keeps coming up with the 'else' message...i think it needs tweeking by someone who knows what their doin... so can anyone help me solve this problem if I send you the files... before my head explodes... Thanks in advance. Paul
wolverine74
June 22nd, 2006, 10:41 AM
<?php
if(isset($_POST['submit'])) {
$to = "paul@the3dge.com";
$subject = "Online Booking Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$dropdown1 = $_POST['drop_down_1'];
$dropdown2 = $_POST['drop_down_2'];
$dropdown3 = $_POST['drop_down_3'];
$date_field = $_POST['date'];
$time_field = $_POST['time'];
$message = $_POST['message'];
$option = $_POST['radio'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Phone: $phone_field\n Drop-Down1: $dropdown1\n Drop-Down2: $dropdown2\n Drop-Down3: $dropdown3\n Date: $date_field\n Time: $time_field\n Message: $message\n Option: $option\n";
echo "Your email is processed and we will contact you shortly";
mail($to, $subject, $body);
} else {
echo "this ain't working!";
}
?>
bwh2
June 22nd, 2006, 10:43 AM
just post the php here that you're using. use the
here's the code. tags.
andr.in
June 22nd, 2006, 10:56 AM
merged the threads ;)
yeah it's good to practice the
tags for readability
bwh2
June 22nd, 2006, 11:02 AM
if you're getting the else message, that means it's not passing isset($_POST['submit']). in that case, your form is not sending the variables correctly. what's the code for your form?
wolverine74
June 22nd, 2006, 12:46 PM
<html>
<body>
<form method="POST" action="booking.php">
<table width="400" height="400" border="0">
<tr bgcolor="#CCCCCC">
<th scope="row"><div align="left"><span class="style1">Name:</span></div></th>
<th scope="row"><div align="left">
<input type="text" name="name">
</div></th>
</tr>
<tr>
<th scope="row"><div align="left"><span class="style1">Email address: </span></div></th>
<th scope="row"><div align="left">
<input type="text" name="email">
</div></th>
</tr>
<tr bgcolor="#CCCCCC">
<th scope="row"><div align="left"><span class="style1">Daytime telephone:</span></div></th>
<th scope="row"><div align="left">
<input type="text" name="phone">
</div></th>
</tr>
<tr>
<th scope="row"><div align="left"><span class="style1">Number of holes: </span></div></th>
<th scope="row">
<div align="left">
<select name="drop_down_1">
<option selected>Please choose...</option>
<option>9</option>
<option>18</option>
<option>36</option>
</select>
</div></th>
</tr>
<tr bgcolor="#CCCCCC">
<th scope="row"><div align="left"><span class="style1">Number of players: </span></div></th>
<th scope="row"><div align="left">
<select name="drop_down_2">
<option>-</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<span class="style1">Buggies:
<select name="drop_down_3">
<option>-</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</span></div></th>
</tr>
<tr>
<th scope="row"><div align="left"><span class="style1">Preferred Date: (DD/MM/YYYY) </span></div></th>
<th scope="row"><div align="left">
<input type="text" name="date">
</div></th>
</tr>
<tr bgcolor="#CCCCCC">
<th scope="row"><div align="left"><span class="style1">Preferred Time: (24Hr clock) </span></div></th>
<th scope="row"><div align="left">
<input type="text" name="time">
</div></th>
</tr>
<tr>
<th valign="top" scope="row"><div align="left"><span class="style1">Other requests: </span></div></th>
<th scope="row"><div align="left">
<textarea name="requests"></textarea>
</div></th>
</tr>
<tr bgcolor="#CCCCCC">
<th scope="row"><div align="left"><span class="style1">Would you like us to send<br>
you golf offers via email: </span></div></th>
<th scope="row"><div align="left">
<span class="style1">Yes </span>
<input type="radio" name="radio" value="yes">
<span class="style1">No</span>
<input type="radio" name="radio" value="no">
</div></th>
</tr>
<tr bgcolor="#999999">
<th scope="row"><div align="right">
</div></th>
<th scope="row"><div align="right">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</div></th>
</tr>
</table>
<p class="style1"> </p>
</form>
</body>
</html>
wolverine74
June 22nd, 2006, 12:48 PM
merged the threads ;)
yeah it's good to practice the
tags for readability
thanks for doing that... still learning my way about...
deletedUser2352352
June 22nd, 2006, 01:37 PM
on a quick look i can see is your submit button uses uppercase S try switching the
if(isset($_POST['submit'])) {
to
if(isset($_POST['Submit'])) {
hope that helps
bwh2
June 22nd, 2006, 02:07 PM
good eye, bugboy.
wolverine74
June 22nd, 2006, 03:17 PM
on a quick look i can see is your submit button uses uppercase S try switching the
if(isset($_POST['submit'])) {
to
if(isset($_POST['Submit'])) {
hope that helps
Not sure what to do... keeps coming up with "Parse error: syntax error, unexpected T_VARIABLE in /usr/local/psa/home/vhosts/the3dge.com/httpdocs/booking.php on line 4"
bwh2
June 22nd, 2006, 03:37 PM
that likely means you didn't modify it correctly. or you changed something in the php. usually parse errors occur in the line before the one that it mentions.
is the php you showed earlier all of booking.php? repost the php you are using now.
deletedUser2352352
June 22nd, 2006, 07:59 PM
i find running back space along the lines and re jigging the returns and Tabs can clear that up as well as for making neater code in the long run.
wolverine74
June 23rd, 2006, 04:59 AM
<?php
echo isset($_POST['Submit'])
if(isset($_POST['Submit'])) {
$to = "paul@the3dge.com";
$subject = "Online Booking Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$dropdown1 = $_POST['drop_down_1'];
$dropdown2 = $_POST['drop_down_2'];
$dropdown3 = $_POST['drop_down_3'];
$date_field = $_POST['date'];
$time_field = $_POST['time'];
$message = $_POST['message'];
$option = $_POST['radio'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Phone: $phone_field\n Drop-Down1: $dropdown1\n Drop-Down2: $dropdown2\n Drop-Down3: $dropdown3\n Date: $date_field\n Time: $time_field\n Message: \n $message\n Option: $option\n";
echo "Your email is processed and we will contact you shortly $to!";
mail($to, $subject, $body);
} else {
echo "this ain't working!";
}
?>
that likely means you didn't modify it correctly. or you changed something in the php. usually parse errors occur in the line before the one that it mentions.
is the php you showed earlier all of booking.php? repost the php you are using now.
andr.in
June 23rd, 2006, 06:02 AM
You're missing a semicolon (;) at the end of the second line (which starts with 'echo')
And btw, wolverine, you can edit your posts as well (the little 'edit' button in the lower right corner of each of your posts) ;)
wolverine74
June 23rd, 2006, 06:57 AM
You're missing a semicolon (;) at the end of the second line (which starts with 'echo')
And btw, wolverine, you can edit your posts as well (the little 'edit' buttont the lower right corner of each of your posts) ;)
Thanks... it works now... :pleased:
deletedUser2352352
June 23rd, 2006, 08:46 AM
glad to hear it dude.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.