Notes
![]() ![]() Notes - notes.io |
<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="firstName">First
Name:</label>
<input type="text" name="first_name"
id="firstName">
</p>
<p>
IU2041050116 SHAH BHAVYA CE-B
<label for="lastName">Last
Name:</label>
<input type="text" name="last_name"
id="lastName">
</p>
<p>
<label for="Gender">Gender:</label>
<input type="text" name="gender"
id="Gender">
</p>
<p>
<label for="Address">Address:</label>
<input type="text" name="address"
id="Address">
</p>
<p>
<label for="emailAddress">Email
Address:</label>
<input type="text" name="email"
id="emailAddress">
</p>
IU2041050116 SHAH BHAVYA CE-B
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Insert.php
<!DOCTYPE html>
<html>
<head>
<title>Insert Page page</title>
</head>
<body>
<center>
<?php
// servername => localhost
// username => root
// password => empty
// database name => staff
$conn = mysqli_connect("localhost"
,
"root"
,
""
,
"staff");
IU2041050116 SHAH BHAVYA CE-B
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form
data(input)
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$gender = $_REQUEST['gender'];
$address = $_REQUEST['address'];
$email = $_REQUEST['email'];
// Performing insert query execution
// here our table name is college
$sql = "INSERT INTO college VALUES
('$first_name'
,
'$last_name'
,
'$gender'
,
'$address'
,
'$email')";
if(mysqli_query($conn, $sql)){
echo "<h3>data stored in a database
successfully."
. " Please browse your localhost php
my admin"
IU2041050116 SHAH BHAVYA CE-B
. " to view the updated data</h3>";
echo nl2br("n$first_namen
$last_namen "
. "$gendern $addressn $email");
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team