I need to have two inputs with a different types:
<input type="button" **onclick = "?????"** name="back" value="← Back" >
<input type="submit" name="submit" value="Forward →" >
How can I do for type=button run this PHP code:
<?php
if (isset($_POST['back']))
{
$_SESSION['onpage'] = $_SESSION['onpage'] - 1;
$query_questionset = "
select Q.Constructor AS Constructor,
QS.QuestionIDFKPK AS QuestionIDFKPK,
Q.QuestionValue AS QuestionValue,
QS.SortOrder AS SortOrder,
QS.onpage AS onpage
from tbluserset AS US
inner join tblquestionset AS QS ON US.QuestionSetIDFKPK = QS.QuestionSetIDPK
inner join tblquestion AS Q ON QS.QuestionIDFKPK = Q.QuestionIDPK
where (US.UserIDFKPK = " . $UserId . ")
and (US.UserSetIDPK= '" . $_SESSION['UserSetIDPK'] . "')
and (QS.onpage = '" . $_SESSION['onpage'] . "')
order by QS.SortOrder";
}
$QuestionSet_Constructors = mysql_query($query_questionset);
?>
My form and input submit works perfectly:
<form id= "formID" class="formular" method="post" action= "<?= $url = "QUESTIONAREnewdatabase.php"; ?>" accept-charset="utf-8">
What I need on input type=button for run that PHP code and the action form like if Back had type=submit?
Here’s one way that uses Javascript, this will dynamically create and append a hidden input called
backto the form, then submit the form – when the back button is clicked.On the server side, you can now test for: