Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Adding Record</title>
- </head>
- <body>
- <?php
- $username="root";
- $password="";
- $hostname="localhost";
- $table_name="student";
- $db_name="IT21KB4";
- //connection to the database
- $db_connection = mysql_connect($hostname, $username, $password)
- or die("unable to connect to MySQL");
- //echo "Connected to MySQL<br>";
- //select a database to work with
- $db_select = mysql_select_db($db_name, $db_connection)
- or die("Could not find ".$db_name);
- $lastname=$_POST['lastname'];
- $firstname=$_POST['firstname'];
- $age=$_POST['age'];
- $ID=$_POST['id'];
- $StudentNo=$_POST['studno'];
- $MI=$_POST['mi'];
- $Year=$_POST['year'];
- $ContactNo=$_POST['contactno'];
- $EmailAdd=$_POST['email'];
- $RegisteredBy=$_POST['regdate'];
- $sql_query="insert into $table_name (lastname, firstname, age, id, studno, mi, year, contactno, email, regdate)
- values('$lastname', '$firstname', $age, $ID, $StudentNo, $MI, $Year, $ContactNo, $EmailAdd, $RegisteredBy)";
- $result=mysql_query($sql_query);
- if($result)
- {
- echo "Successfully<br>";
- echo "<a href=view.php>View</a>";
- }
- else
- {
- echo "ERROR";
- }
- mysql_close($db_connection);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment