2013-04-09 60 views
0

提交我的形式我有3個提交,我想知道處理這些按鈕的最好方式,因爲默認的動作是一樣的形式:多的形式PHP

<form method="POST" action="file_where_form_is.php"> 
     Name:<input type='text' name='name'> 
     <input type='submit' name='add' value='Add Names' ONCLICK='window.location.href="file_where_form_is.php"> 
     <input type='submit'name='Preview'value='Preview'ONCLICK='window.location.href="file_where_form_is.php"> 
     <input type='submit' name='submit'value='Submit' ONCLICK='window.location.href="send.php">           

</form> 

這不是看起來完全正常工作,只是第一件作品和最後一次提交沒有任何作用(名稱='submit') 有什麼建議嗎?

+0

你有什麼期待碰巧/意欲何爲? – 2013-04-09 22:41:15

+0

我在預覽了我添加的名稱後,在表中添加了一些名稱,然後添加了In Database(send.php) – Alex 2013-04-09 22:48:26

回答

1

我終於在頭部分發現添加像這樣:

if(isset($_POST['submit'])){ 
     header("location: somefile.php"); 
} 
elseif(isset($_POST['Preview'])){ 
     header("location: anotherfile.php"); 
} 
elseif(isset($_POST['add'])){ 
     header("location: anotheronefile.php"); 
}