WBP Exp 15

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Oaish Qazi 1|Page

Practical No 15:

Q. Write a Program to create a form and store the entered data in the database also displays the
entered data.
CODE:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["username"];
$password = $_POST["password"];

$con = mysqli_connect('localhost', 'root', '', 'wbpexp');


$sql = "INSERT INTO users (username, password) VALUES ('$username', '$password')";
$result = mysqli_query($con, $sql);
echo "Username: " . $username . "<br> Password: " . $password;
exit(0);
}
?>

<form action="" method="post">


<label>
Username:
<input type="text" name="username" placeholder="Enter Username">
</label> <br>

<label>
Password:
<input type="password" name="password" placeholder="Enter Password">
</label> <br>

<input type="submit" value="Submit">


</form>

OUTPUT:

You might also like