pgs_php_insert_upate1.htm |
|
Script :
if($_REQUEST['fname'] && $_REQUEST['lname'] && $_REQUEST['address']&&
$_REQUEST['manager'])
{
pg_connect("host=$host dbname=$db user=$user password=$pass") or
die("Couldn't Connect"); // Connect to the Database
$query = sprintf("INSERT INTO emp1 VALUES('%s','%s','%s','%s','%s')",$_REQUEST['ID'],$_REQUEST['fname'],$_REQUEST['lname'],$_REQUEST['address'],$_REQUEST['manager']);
// Form the Query
$query = pg_query($query);
if($query)
echo "You were successfully added to the database!";
else
echo "Some Error Occured! ".pg_last_error();
}
else{ // If we dont have all of the fields, show the form
echo "not sure";
}
|
Super users has all rights: owner has all DML/DMLprivileges.

|
Now let us add some data as the owner of emp1 table.


|
Note: ID is out of sequence

|
Let us Update the ID 
Now verify the updates. OOPs, address needs to be corrected

Correcting address:

Final checks on the update operations.

|
Complete PHP script:
<?php
$host = "localhost";
$user = "manas237";
$pass = "pwmanas237";
$db = "pgsdemo1";
// open a connection to the database server
if($_REQUEST['fname'] && $_REQUEST['lname'] && $_REQUEST['address']&&
$_REQUEST['manager'])
{
pg_connect("host=$host dbname=$db user=$user password=$pass") or
die("Couldn't Connect"); // Connect to the Database
$query = sprintf("INSERT INTO emp1 VALUES('%s','%s','%s','%s','%s')",$_REQUEST['ID'],$_REQUEST['fname'],$_REQUEST['lname'],$_REQUEST['address'],$_REQUEST['manager']);
// Form the Query
$query = pg_query($query);
if($query)
echo "You were successfully added to the database!";
else
echo "Some Error Occured! ".pg_last_error();
}
else{ // If we dont have all of the fields, show the form
echo "not sure";
}
?>
|
|