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 Respuesta
+ 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);