Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i select buttons using php and enter into database?
    primarykey
    data
    text
    <p>Here is my current code..</p> <pre><code>&lt;form action="js.php" method="post"&gt; &lt;input type="button" id='approve' value="Yes" onclick="a()" class="approve" /&gt; &lt;input type="button" id='reject' value="No" onclick="r()" class="reject"/&gt; &lt;input type="submit" name="submitted" value="TRUE" /&gt; &lt;/form&gt; </code></pre> <p>This is my form and the page title is js.php..</p> <p>I want that if the user clicks on any of the button the name of the button should bge entered into the database into a table called response under the heading response.</p> <p>How Do i do that?Thanks..</p> <p>I have done some PHP part...</p> <pre><code>&lt;?php require_once('connect.php'); if(isset($_POST['submitted'])) { //if on button click mysqli_select_db($connect,"check"); //entering query } ?&gt; </code></pre> <p>here is what Im using to enter the data</p> <pre><code>&lt;?php require_once('connect.php'); //if on button click mysqli_select_db($connect,"pubd"); //entering query if ($_POST['action'] == 'approve') { // user clicked Yes $yes = "insert into response (button) values ('approve')"; $yesr = mysqli_query($connect,$yes) or die(mysqli_error($connect)); } else if ($_POST['action'] == 'reject') { $no = "insert into response (button) values ('reject')"; $nor = mysqli_query($connect,$no) or die(mysqli_error($connect)); } ?&gt; &lt;form action="js.php" method="post"&gt; &lt;input type="button" id='approve' name="action" value="Approve" onclick="a()" class="approve" /&gt; &lt;input type="button" id='reject' value="Reject" name="action" onclick="r()" class="reject"/&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload