-1

I'm aware about passing user input to another php page, get it by $_POST or GET and run a query, but I see in some pages that when I give them an input it's saved immediately, without going to another link. I don't know whether they are using mySQL database, but I want to know how to make that possible in the case of mySQL. Is the data saved in a JSON file or something and passed to the server when the page is closed?

Gunhee Yi
  • 5
  • 3

1 Answers1

0

For that you can use Ajax or write php code on the same page. For example :

<form action="" method="POST">
<input type="text" placeholder="Input1" name="firstInput">
<input type="submit" name="submit">
</form>
<?php 

if(isset($_POST['submit'])){

$input=$_POST['firstInput'];

 //Here you can run your query make sure to make database connection first
$sql=mysqli_query($con,"query goes here"); 
}

?>
Xhuljo
  • 689
  • 6
  • 12