Guest User

Untitled

a guest
Jan 21st, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Adding Record</title>
  4. </head>
  5.  
  6. <body>
  7. <?php
  8. $username="root";
  9. $password="";
  10. $hostname="localhost";
  11. $table_name="student";
  12. $db_name="IT21KB4";
  13.  
  14. //connection to the database
  15. $db_connection = mysql_connect($hostname, $username, $password)
  16. or die("unable to connect to MySQL");
  17. //echo "Connected to MySQL<br>";
  18.  
  19. //select a database to work with
  20. $db_select = mysql_select_db($db_name, $db_connection)
  21. or die("Could not find ".$db_name);
  22.  
  23. $lastname=$_POST['lastname'];
  24. $firstname=$_POST['firstname'];
  25. $age=$_POST['age'];
  26. $ID=$_POST['id'];
  27. $StudentNo=$_POST['studno'];
  28. $MI=$_POST['mi'];
  29. $Year=$_POST['year'];
  30. $ContactNo=$_POST['contactno'];
  31. $EmailAdd=$_POST['email'];
  32. $RegisteredBy=$_POST['regdate'];
  33. $sql_query="insert into $table_name (lastname, firstname, age, id, studno, mi, year, contactno, email, regdate)
  34. values('$lastname', '$firstname', $age, $ID, $StudentNo, $MI, $Year, $ContactNo, $EmailAdd, $RegisteredBy)";
  35.  
  36. $result=mysql_query($sql_query);
  37. if($result)
  38. {
  39. echo "Successfully<br>";
  40. echo "<a href=view.php>View</a>";
  41. }
  42. else
  43. {
  44. echo "ERROR";
  45. }
  46.  
  47. mysql_close($db_connection);
  48. ?>
  49. </body>
  50. </html>
Add Comment
Please, Sign In to add comment