PHP不显示HTML输入

时间:2018-10-13 21:00:47

标签: php html

我仍然停留在此PHP代码上。我正在尝试在用户输入一些信息的地方对其进行编码,而PHP代码会显示用户输入的信息。基本上,我试图构建一个确认页面,以便用户在提交信息之前先查看输入的信息。

HTML

<DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>DormAngel Booking Form</title>
	</head>
	<body>
		<form action="welcome.php" method="POST">
			<fieldset>
				<legend> Personal Details: </legend>
					<label for="fname>"></label>
						<input type="text" name="Name" id="fname" required autofocus placeholder="First Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
					<label for="lname>"></label>
						<input type="text" name="Last Name" id="lname" required autofocus placeholder="Last Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
					<label for="email">Email: </label>
						<input type="text" name="email" id="email" required placeholder="Your school email" pattern="[a-zA-Z]{3,}@[a-zA-Z]{3,}[.]{1}[a-zA-Z{2} title="Please enter a valid email address>
					<label for="phone">Phone: </label>
						<input type="tel" name="phone" id="phone" required placeholder="Please enter in your phone number">
				<select name="country" required>
					<option value=""> </option> 
					<option value="US">US</option>
					<option value="UK">UK</option>
					<option value="AUS">AUS</option>
				</select>
			</fieldset>
			<br>
			<fieldset>
				<legend> Booking Details: </legend>
				<input type="date" name="date" min="2018-10-07" max="2018-10-31">
				<input type=time min=9:00 max=17:00 step=900> 
				<br>
				<br>
				<label for="dorm">Dormitory: </label>
				<br>
				<select name="dorm" required>Dormitory
					<option value="Cypress">Cypress Hall</option>
				</select>
				<br>
				<br>
				<label for="floor">Floor: </label>
				<br>
				<select name="floor" required>Floor: 
					<option value=""></option>
					<option value="02">02</option>
					<option value="03">03</option>
					<option value="04">04</option>
					<option value="05">05</option>
					<option value="06">06</option>
					<option value="07">07</option>
					<option value="08">08</option>
				</select>
				<br>
				<br>
				<label for="roomnumber">Room Number: </label>
				<br>
				<select name="roomnumber">Room Number: 
					<option value=""></option>
					<option value="22">22</option>
				</select>
				<br>
				<br>
				<label for="roomletter">Room Letter: </label>
				<br>
				<select name="roomletter" required="">Room Letter
					<option value=""></option>
					<option value="A">A</option>
					<option value="B"> B</option>
				</select>
				<button type="submit">Submit</button>
			</fieldset>
		</form>  		
	</body>
</html>

PHP

<html>
<head>
<title>Confirmation Page of Web Form</title>
</head>
<h1>Confirmation Page of Customer Info</h1>

<p>Thank you for submitting this form.</p>

<p>We have successfully received it.</p>

<p>Below is a summary of the information you provided.<br><br>  
<?php
echo 'First Name: ' . $_POST ["Name"] . '<br>';
echo 'Last Name: ' . $_POST ["Last Name"] . '<br>';
echo 'Email Address: ' . $_POST ["email"] . '<br>';
echo 'Telephone Number: ' . $_POST ["phone"];
?>
</p>
</html>

我的代码有什么问题?

2 个答案:

答案 0 :(得分:-1)

您忘记了html中的<body>标记。

答案 1 :(得分:-1)

以这种方式替换代码。

        <html>
    <head>
    <title>Confirmation Page of Web Form</title>
    </head>
    <h1>Confirmation Page of Customer Info</h1>

    <p>Thank you for submitting this form.</p>

    <p>We have successfully received it.</p>

    <p>Below is a summary of the information you provided.<br><br>  
    <?php
    echo 'First Name: ' . $_POST["Name"] . '<br>';
    echo 'Last Name: ' . $_POST["Last Name"] . '<br>';
    echo 'Email Address: ' . $_POST["email"] . '<br>';
    echo 'Telephone Number: ' . $_POST["phone"];
    ?>
    </p>
    </html>