我正在研究一个班级项目,我需要一个有效的表格。我正试图让它工作,但每次我点击提交按钮,它会把我带到一个空白页面。我知道有些事情是错的,因为我在这个主题上找到了其他问题,但没有一个答案有帮助。所以这就是我所拥有的(缩减版本的简化版本):
HTML:
Email address*:<br> <input type="text" name="email" required>
<br>
</fieldset>
<br>
<br>
<fieldset>
<legend>Room Information</legend>
Which room would you like us to reserve for you?<br>
<select name="Room">
<option value="TeaRoom">The Tea Room</option>
<option value="CaptainsSuite">The Captain's Suite</option>
<option value="GreenRoom">The Green Room</option>
<option value="Valentine">The Valentine Suite</option>
<option value="Turkish">The Turkish Delight</option>
<option value="Music">The Music Room</option>
<option value="Bridal">The Bridal Suite</option>
<option value="GuestCottage">The Guest Cottage</option>
</select>
<br><br>
How many people are in your party?<br>
<input type="radio" name="number" value="1">1<br>
<input type="radio" name="number" value="2">2<br>
<input type="radio" name="number" value="3">3<br>
<input type="radio" name="number" value="4">4<br>
<br><br>
Date of Check In:<br> <input type="text" name="checkindate"><br>
<br>
Date of Check Out:<br><input type="text" name="checkoutdate">
<br>
<br>
Do you, or anyone in your party, have any special dietary requirements?<br>
<textarea rows="4" cols="50" name="comment">
</textarea>
<br>
</fieldset>
<br>
<br>
<input type="submit" value="Submit">
PHP:
<?php
$field_name = $_POST['name'];
$field_address = $ POST ['address'];
$field_city = $ POST ['city'];
$field_homephone = $ POST ['homephone'];
$field_cellphone = $ POST ['cellphone'];
$field_email = $_POST ['email'];
$field_Room = $ POST ['Room'];
$field_checkindate = $ POST ['checkindate'];
$field_checkoutdate = $ POST ['checkoutdate'];
$field_comment = $ POST ['comment'];
$radio_button = $_POST['number'];
$drop_down_item = $_POST['state'];
$mail_to = 'email@student.umuc.edu';
$subject = 'Reservation '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly with your confirmation.');
window.location = 'contactpage.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to eburns15@studentumuc.edu');
window.location = 'contactpage.html';
</script>
<?php
}
?>
编辑:我意识到这是一个重复的问题。我问这个是因为我想知道我做错了什么,因为这个问题已被重复,因为不是对我有所帮助。
答案 0 :(得分:0)
您使用$_POST
空间$ POST
时出现错误。
$field_name = $_POST['name'];
$field_address = $_POST ['address'];
$field_city = $_POST ['city'];
$field_homephone = $_POST ['homephone'];
$field_cellphone = $_POST ['cellphone'];
$field_email = $_POST ['email'];
$field_Room = $_POST ['Room'];
$field_checkindate = $_POST ['checkindate'];
$field_checkoutdate = $_POST ['checkoutdate'];
$field_comment = $_POST ['comment'];
$radio_button = $_POST['number'];
$drop_down_item = $_POST['state'];