php - Multiple buttons and 'a' tags that post from a single page
266
I have multiple buttons and a tags that are submitted from a single view. The 'a' tag submits using javascript. I want to use the same method, one form post, but I want to check which button or 'a' tag is set. I don't know how to do that?
if (isset($_POST['a_tag_name'])) {
//data table 1
}elseif(isset($_POST['a_tag_name2'])){
//different data from table 2
} //calling buttons
elseif (isset($_POST['en'])) {
$language = 'en';
} elseif (isset($_POST['sq'])) {
$language = 'sq';
} elseif (isset($_POST['tr'])) {
$language = 'tr';
}
<a id="slider-content-link" onclick="javascript:getimageid('{{$row->id}}')" id="view_post">
<h3 >
<p align="right">{{$row->title}}</p>
</h3>
</a>
Answer
Solution:
Make your "buttons" be actually "submit buttons".
Only the submit button you click will be passed as parameter in the post. Then just check which of all the submit is passed, and there you have it.