WT 13
WT 13
WT 13
Php:
<!DOCTYPE html>
<html lang="en">
<head>
<title>GFG- Store Data</title>
</head>
<body>
<center>
<h1>Storing Form data in Database</h1>
<form action="insert.php" method="post">
<p>
<label for="id">id:</label>
<input type="text" name="id" id="id">
</p>
<p>
<label for="lastName">Name:</label>
<input type="text" name="name" id="name">
</p>
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Insert:
<!DOCTYPE html>
<html>
<head>
<title>Insert Page page</title>
</head>
<body>
<center>
<?php
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
$id= $_REQUEST['id'];
$name = $_REQUEST['name'];
if(mysqli_query($conn, $sql)){
echo "<h3>data stored in a database successfully."
. " Please browse your localhost php my admin"
. " to view the updated data</h3>";
echo nl2br("\n$name");
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>
Output:
First:
Second: