0
How to send data from HTML to DB using PHP?
Collecting User input with a form in html, how can the data be sent to a MySQL database using php-code?
1 Answer
+ 1
Hi Philipp
hereâs a solution although it would probably be faster to just google an answer next time to a question like this...
html
<form action=âprocess.phpâ method=âpostâ>
<input type=âtextâ name=âunameâ/>
</form>
process.php
Define("DBUSER", "root");
Define("DBPASS", "");
Define("DBHOST", "localhost");
Define("DBNAME", âDATABASENAME");
$dbcon = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
mysqli_set_charset($dbcon, "utf8");
$query = âINSERT INTO tablename (collums seperated by comma) VALUES (values to match collums seperated by commas)â;
$q = mysqli_stmt_init($dbcon);
mysqli_stmt_prepare($q, $query);
mysqli_stmt_bind_param($q, âsâ, $_POST[âunameâ]);
mysqli_stmt_execute($q);