Application Sketch home htm display php insertform htm

  • Slides: 9
Download presentation
Application Sketch home. htm display. php insertform. htm updateform. php update. php delete. php

Application Sketch home. htm display. php insertform. htm updateform. php update. php delete. php insert. php Data Base Hyperlink Information exchange with database Redirection Submit data via post Hyperlink with URL appended data

home. html <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF"

home. html <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><a href=". . /home. htm">Main Home Page</a></p> <p><a href="display. php">View Records</a></p> <p><a href=“insertform. htm">Enter Records</a></p> </body> </html>

insertform. htm <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF"

insertform. htm <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><a href="home. htm">home</a></p> <form name="form 1" method="post" action="insert. php"> <p>Name <input type="text" name="name"> </p> <p>Age <input type="text" name="age"> </p> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html>

insert. php <? // script to display all the records in a table //

insert. php <? // script to display all the records in a table // connection information $host. Name = "dbm 1. itc. virginia. edu"; $user. Name = “user"; $password = “password"; $db. Name = “dbname"; // make connection to database mysql_connect($host. Name, $user. Name, $password) or die( "Unable to connect to host $host. Name"); mysql_select_db($db. Name) or die("Unable to select database $db. Name"); // Insert Data into table 1 $query = "INSERT INTO table 1 (name, age) VALUES ('$name', '$age')"; $result = mysql_query($query); // Close the database connection mysql_close(); header("Location: home. htm"); ? >

display. php (part 1) <html> <head> <title>Data Display</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><a href="home.

display. php (part 1) <html> <head> <title>Data Display</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><a href="home. htm">home</a></p> <? // script to display all the records in a table // connection information $host. Name = "dbm 1. itc. virginia. edu"; $user. Name = “user"; $password = “password"; $db. Name = “dbname"; // make connection to database mysql_connect($host. Name, $user. Name, $password) or die( "Unable to connect to host $host. Name"); mysql_select_db($db. Name) or die("Unable to select database $db. Name"); // Select all the fields in all the records of table 1 $query = "SELECT * FROM table 1 ORDER BY ID"; $result = mysql_query($query);

display. php (part 2) // Determine the number of employees $number = mysql_numrows($result); //

display. php (part 2) // Determine the number of employees $number = mysql_numrows($result); // Print the employee names echo("There are $number employees: <p>"); $i = 0; While ($i<$number) { $ID = mysql_result($result, $i, "ID"); $name = mysql_result($result, $i, "name"); $age = mysql_result($result, $i, "age"); echo("<a href="updateform. php? ID=$ID&name=$name&age=$age">Update</a> $name $age <a href="delete. php? ID=$ID">Delete</a> "); $i = $i + 1; } // Close the database connection mysql_close(); ? > </p> </body> </html>

updateform. php <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF"

updateform. php <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 -1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <p><a href="home. htm">home</a></p> <form name="form 1" method="post" action="update. php"> <p>Name <input type="text" name="name" value="<? echo("$name")? >"> <input type="hidden" name="ID" value="<? echo("$ID")? >"> </p> <p>Age <input type="text" name="age" value="<? echo("$age")? >"> </p> <input type="submit" name="Submit" value="Submit"> </p> </form> <p>  </p> </body> </html>

update. php <? // script to display all the records in a table //

update. php <? // script to display all the records in a table // connection information $host. Name = "dbm 1. itc. virginia. edu"; $user. Name = “user"; $password = “password"; $db. Name = “dbname"; // make connection to database mysql_connect($host. Name, $user. Name, $password) or die( "Unable to connect to host $host. Name"); mysql_select_db($db. Name) or die("Unable to select database $db. Name"); // Select all the fields in all the records of table 1 $query = "UPDATE table 1 SET name = '$name', age = '$age' WHERE ID = '$ID'"; $result = mysql_query($query); // Close the database connection mysql_close(); header("Location: display. php"); ? >

delete. php <? // script to display all the records in a table //

delete. php <? // script to display all the records in a table // connection information $host. Name = "dbm 1. itc. virginia. edu"; $user. Name = “user"; $password = “password"; $db. Name = “dbname"; // make connection to database mysql_connect($host. Name, $user. Name, $password) or die( "Unable to connect to host $host. Name"); mysql_select_db($db. Name) or die("Unable to select database $db. Name"); // Select all the fields in all the records of table 1 $query = "DELETE FROM table 1 WHERE ID = '$ID'"; $result = mysql_query($query); // Close the database connection mysql_close(); header("Location: display. php"); ? >