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?
Asked
Active
Viewed 691 times
-1
-
there's no way for us to know about the specific site's you're referring to since it could be done many ways. chances are pretty high they used ajax. – But those new buttons though.. Nov 24 '18 at 04:46
-
Look into AJAX e.g. https://stackoverflow.com/questions/9436534/ajax-tutorial-for-post-and-get – Nick Nov 24 '18 at 04:47
-
use ajax call and on success you can redirect wherever you want to redirect – Parvej Alam Nov 24 '18 at 04:57
-
1yeah maybe also consider ajax. or even ajax. – But those new buttons though.. Nov 24 '18 at 05:05
1 Answers
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