I am having a form in which 2 inputs like below:
<input class="view" type="submit" name="viewonly" value="View">
<input class="submit" type="submit" name="vote" value="Vote">
I want to achieve this:
if(hit on input with name 'viewonly') {
echo 'you choose viewonly';
}
elseif(hit on input with name 'vote') {
echo 'you choose vote';
}
How can i do that?
Update: My form:
<form method="post" id="quickpoll">
.........
<input class="view" type="submit" name="quickpollsubmit" value="View">
<input class="quickpollsubmit" type="submit" name="quickpollsubmit" value="Vote">
</form>
The ajax call:
$(document).on('submit', '#quickpoll', function()
{
var data = $(this).serialize();
$.ajax({
type : 'POST',
url : 'quickpoll_vote.php',
data : data,
success : function(data)
{
$("#quickpoll").fadeOut(500).hide(function()
{
$(".quickpollwrapper").fadeIn(500).show(function()
{
$(".quickpollwrapper").html(data);
});
});
}
});
return false;
});
quickpoll_vote.php
if($_POST)
{
if($_POST['quickpollsubmit'] == 'Vote') {
echo 'you did vote and not view only';
}
The echo does not appear, so the problem is i think in the AJAX call?