Insert record
<form name='forminsert' method='get' action=''>
Employee no
<input name='txtempno' type='text' maxlength=6> <br>
Firstname
<input name='txtfname' type='text'> <br>
Lastname
<input name='txtlname' type='text'> <br>
Department
<input name='txtdept' type='text'> <br>
Extension
<input name='txtphone' type='text'> <br>
<input name='submit' type='submit' value='Save'> <br>
</form>
<?php
//extract all info from the form
$empno=$_GET['txtempno'];
$fname=$_GET['txtfname'];
$lname=$_GET['txtlname'];
$dept=$_GET['txtdept'];
$ext=$_GET['txtphone'];
//develop the SQL command
if($empno!=''){
$sql="insert into employee
(EMPNO, FIRSTNAME, LASTNAME,WORKDEPT, PHONENO)
values
('$empno', '$fname', '$lname', '$dept', '$ext')";
//database connect
$db=mysqli_connect("localhost","root","","mycompanyhr");
// database connection
if ($db==false) {
echo "Connect failed: ". mysqli_connect_error($db);
exit();
}
else {
echo "Connection successful";
}
//execute the SQL command
$rs=mysqli_query($db,$sql);
//check the execution status
if($rs==false){
echo "Record cannot be saved!<br>";
echo "SQL Error : ".mysqli_error($db);
}
else{
echo "<br>Record for $fname saved!<br>";
echo "<a href='listing-table.php'>
List records</a><br>";
}
}//end NULL
?>
Insert a new record
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Or you could download here for the Malay proverbs app – https://play.google.com/store/apps/details?id=net.kerul.peribahasa English prove...
-
This is one of my Android phone, bought specially to test our m-DictionaryApp project . I bought it on the last September 2010 (sponsored by...
-
I’ve been trying to release this tutorial quite a while. At last after a long hard effort. Since HttpClient is not supported any more in...
-
This code is a simple code for Android application. It has two textboxes to receive two numbers (decimal), list of mathematical operations w...
-
This tutorial is tested on Honeycomb 3.0 environment. In order to be used it in the lower level of Android API, I believe you could just cha...
-
HTML without framework is dull. Doing hard-coded CSS and JS are quite difficult with no promising result on cross platform compatibility....

No comments:
Post a Comment