Site icon DataFlair

How to Execute Parameterized Query in PHP GUI Application

Program 1

<html>
<body>
    <center>
        <form method=post action="InsertStudent1.php">
      <table border=1>  
        <tr>
            <th>Student Id</th>
            <td><input type=text name=txtid></td>
        </tr>
        <tr>
            <th>Name</th>
            <td><input type=text name=txtname></td>
        </tr>
        <tr>
            <th>Physics</th>
            <td><input type=text name=txtphy></td>
        </tr>
        <tr>
            <th>Chemistry</th>
            <td><input type=text name=txtchem></td>
        </tr>
        <tr>
            <th>Maths</th>
            <td><input type=text name=txtmath></td>
        </tr>
        <tr>
        <td></td>
        <td><input type=submit value=Submit name=btnSubmit></td>
        </tr>
</table> 
<pre>
<?php

     if(isset($_POST['btnSubmit']))
     {
        $id=$_POST['txtid'];
        $name=$_POST['txtname'];
        $phy=$_POST['txtphy'];
        $chem=$_POST['txtchem'];
        $math=$_POST['txtmath'];
        
        $mycon=mysqli_connect("localhost","root","","Library") or die("Connection not success");
        echo "Connection sucees<br>"; 
        // $sql="insert into studentdata values(?,?,?,?,?)";
        // $ps=$mycon->prepare($sql);
        // $ps->bind_param("isiii", $id,$name,$phy,$chem,$math);
        // $ps->execute();
        // echo " Record inserted....";
 $ps->close();
          $mycon->close();        
 
        

    // i-integer , s-string , d-double,b-Blob

     }

?>
</pre>
</center>
</body>
</html>

 

Exit mobile version