我有一个可以工作的PHP文件,我只是想在底部做一个按钮,当你点击它时,它会带你到另一个PHP文件,显示"购买成功!我错过了什么?
这是第一个 PHP:
<!DOCTYPE>
<html>
<head>
<title>Confirmation Page</title>
<style>
</style>
</head>
<body bgcolor="#E6E6FA">
<h2>Customer:</h2>
<?php
//Check whether the form has been submitted
if (array_key_exists('check_submit', $_POST)) {
//Converts the new line characters ('n) in the text area into HTML line breaks (the <br /> tag)
$_POST['Comments'] = nl2br($_POST['Comments']);
//Check whether a $_GET['Languages'] is set
if ( isset($_POST['Colors']) ) {
$_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string
}
//Let's now print out the received values in the browser
echo "Your first name: {$_POST['firstName']}<br />";
echo "Your last name: {$_POST['lastName']}<br /><br />";
echo "Your address:<br />{$_POST['address']}<br /><br />";
echo "Your phone number: {$_POST['phone']}<br /><br />";
echo "Your favourite gaming console: {$_POST['console']}<br /><br />";
echo "Games you choose to purchase: {$_POST['games']}<br /><br />";
echo "Card being used: {$_POST['card']}<br />";
echo "Card Number: {$_POST['cardnumber']}<br />";
echo "Card Expiration Date: {$_POST['expdate']}<br /><br />";
} else {
echo "You can't see this page without submitting the form.";
}
?>
<form action="assign11_a.php"></form>
<input type="submit" value="Submit">
</body>
</html>
这就是我想去的地方:
<!DOCTYPE>
<html>
<head>
<title>Purchase Successful!</title>
<style>
</style>
</head>
<body bgcolor="#E6E6FA">
<h2>Purchase Successful!</h2>
<?php
?>
</body>
</html>
输入按钮应该在表单内
你有:
<form action="assign11_a.php"></form>
<input type="submit" value="Submit">
不在<form>
内的表单元素将不会提交。没有name
属性的表单元素也不会提交。
<form etc..>
<input type="submit" name="submit_check" value="Submit">
</form>
会工作。
请更正您的代码:
更正前 :
<form action="assign11_a.php"></form>
<input type="submit" value="Submit">
更正后:
<form action="assign11_a.php">
<input type="submit" value="Submit" name="check_submit">
</form>