First the connection page-
I have named it as "connection.php"
$link=mysql_connect('127.0.0.1','root','');
if(!$link)
{
die('Error Connecting to Server. '.mysql_error());
}
$select_db=mysql_select_db('telephone',$link);
if(!$select_db)
{
die('Error Connecting to Database '.mysql_error());
}
// clear the cache
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
$ExpStr = "Expires: " . gmdate("D, d M Y H:i: s ", time() ) . " GMT";
header($ExpStr);
header('Cache-Control: public, no-cache');
?>
Now the main Page.
I have named it as "resultname.php"
include("connection.php");
$searchname = $_REQUEST['searchname'];
if($_REQUEST["ADD"])
{
$id = $_REQUEST['id'];
$name = $_REQUEST['name'];
$mobile1 = $_REQUEST['mobile1'];
$mobile2 = $_REQUEST['mobile2'];
$mobile3 = $_REQUEST['mobile3'];
$lan1 = $_REQUEST['lan1'];
$lan2 = $_REQUEST['lan2'];
$address = $_REQUEST['address'];
$email = $_REQUEST['email'];
mysql_query("insert into record
(name,mobile1,mobile2,mobile3,lan1,lan2,address,email)
values
('$name','$mobile1','$mobile2','$mobile3','$lan1','$lan2','$address','$email')");
if(mysql_affected_rows() > 0)
{
$msg = "Records Inserted Successfully";
}
else
{
$msg = "Error! record not inserted";
}
}
if($_REQUEST['mode']=="add")
{?>
}
if($_REQUEST["Update"])
{
$id = $_REQUEST['id'];
$name = $_REQUEST['name'];
$mobile1 = $_REQUEST['mobile1'];
$mobile2 = $_REQUEST['mobile2'];
$mobile3 = $_REQUEST['mobile3'];
$lan1 = $_REQUEST['lan1'];
$lan2 = $_REQUEST['lan2'];
$address = $_REQUEST['address'];
$email = $_REQUEST['email'];
$sql = "UPDATE record SET
name = '$name' , mobile1 = '$mobile1' , mobile2 = '$mobile2' , mobile3 = '$mobile3' , lan1 = '$lan1' , lan2 = '$lan2' , address = '$address' , email = '$email' WHERE id='$id'";
$result = mysql_query($sql);
if(mysql_affected_rows()>0)
{
$msg = "Updation Completed Successfully";
}
else
{
$msg = "Updation failed";
}
}
if($_REQUEST['mode']=="edit")
{
$result = mysql_query("select * from record where id=".$_GET['id']);
$myrow = mysql_fetch_array($result);?>
}
if($_REQUEST['mode']=="delete")
{
mysql_query("delete from record where id=".$_GET['id']);
$msg = "Record Deleted Successfully.";
}
?>
| Welcome To the Telephone Directory Management System |
| Record |
|
|
";} else {echo $msg." ";} ?> |
| Name | Mobile1 | Mobile2 | Mobile3 | Lan1 | Lan2 | Address | |||
|
&name=" onClick="return confirm('Are You Sure you Want to edit: ?')"> |
" onClick="return confirm('Are You Sure you Want to delete: ?')"> |
Now the MYSQl Portion
first create a database named-"telephone"
Now the table structure.I have named the table as "record"
now copy paste this command
CREATE TABLE IF NOT EXISTS `record` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`mobile1` varchar(15) NOT NULL,
`mobile2` varchar(15) NOT NULL,
`mobile3` varchar(15) NOT NULL,
`lan1` varchar(15) NOT NULL,
`lan2` varchar(15) NOT NULL,
`address` varchar(100) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
)
I think that will be all.If you find any problem feel free to contact me @
dasgupta.rony@gmail.com
This is basically for the begainers and doesnot cointain any complexity.
Hope to meet you all very soon.
