Assign 1
Assign 1
Khaled Mahmoud
Ci893
Installing and initiating
1- For creating database, first we need to use DBMS like MYSQL workbench or anything else, in this
assignment I will use phpMyAdmin, I will connect to it using xampp.
4- To open DBMS
go to any web browser and write in the link bar (localhost) this page will come:
Then we click on phpMyAdmin on the top right, and this will come:
This is the DBMS, and here we will create our database and tables. But there are three methods to do this:
Creating database
You will notice on the left that your database has been created.
notice that now we have a table called test with three columns, to show the table we will write this syntax:
Steps in details:
We have finished the first two steps now we need to make HTML form and PHP connection.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact Form - PHP/MySQL Demo Code</title>
</head>
<body>
<fieldset>
<legend>Form</legend>
<form name="frmContact" method="post" action="contact.php">
<p>
<label for="Name">Name </label>
<input type="text" name="txtName" id="txtName">
</p>
<p>
<label for="adress">adress</label>
<input type="text" name="txtadress" id="txtadress">
</p>
<p> </p>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit">
</p>
</form>
</fieldset>
</body>
</html>
<?php
// database connection code
// $con = mysqli_connect('localhost', 'database_user',
'database_password','database');
// insert in database
$rs = mysqli_query($con, $sql);
if($rs)
{
echo "Records Inserted successfully";
}
?>
3- Now we open the html file and change the path from the link bar into "local host\html"
:After completing the form and submitting, this page should appear
:And you will find the data have been inserted into the database