0
How to get information filled by the user in my html form
htlm and database
5 Answers
+ 3
You need a server-side application to receive the information. The method will vary depending on what you use. Try learning more about the matter, or ask more specific questions.
+ 2
I don't understand the fixation with pointing towards PHP. Yes, somehow, it's still the most relevant server-side language, but there's no guarantee that PHP is what he wants, and Ruby on Rails/Node.js are plenty popular as well. I personally suggest Node if you're up for building the server application yourself, and Rails if you want something easier.
+ 2
You need PHP and Mysql.
Below is the Php code that performs create new database data of username and email upon form submission.
(rĻ
n Ī¹Ń ŅroŠ¼ a php weŠ² Ńerver wĪ¹ŃŠ½ Š¼yŃql dŠ² setup, noŃ ŅroŠ¼ code playgroĻ
nd)
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8">
<title>Add Email Form</title>
</head>
<body>
<form method="post">
<p>
<label for="name">Username:</label>
<input type="text" name="name" id="name">
</p>
<p>
<label for="email">Email Address:</label>
<input type="text" name="email" id="email">
</p>
<input type="submit" value="Send">
</form>
</body>
</html>
<?php
if(!empty($_POST['name']) && !empty($_POST['email'])) {
$link = mysqli_connect("localhost", "root", "password", "demo"); // Check connection demo database
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
} // Escape user inputs for security
$name = mysqli_real_escape_string($link, $_POST['name']);
$email = mysqli_real_escape_string($link, $_POST['email']);
// attempt insert query execution
$sql = "INSERT INTO persons (name, email) VALUES ('$name', '$email')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
}
else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
}
?>
https://code.sololearn.com/w8uC90WWcV3D/?ref=app
0
Most likely with PHP