2014-12-04 62 views
0

我有這個PHP文件的工作原理,我只是想在底部做一個按鈕,當你點擊它時,它會帶你到另一個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> 

回答

2

您有:

<form action="assign11_a.php"></form> 
<input type="submit" value="Submit"> 

表單元素NOT插入將不會提交<form>。沒有name屬性的表單元素也不會被提交。

<form etc..> 
    <input type="submit" name="submit_check" value="Submit"> 
</form> 

會起作用。

4

輸入按鈕應該是內部形狀

+0

哦,是啊,就是這樣!謝謝! – 2014-12-04 17:14:06

1

請更正代碼:

更正前:

<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>