Hi Friends, am new for php. here am doing insert,update,delete,displays. have done insert,delete & view scripts but cant do update script, here i had paste my update script.. anybody can clear me & help me My Update Code :- <?php $dbconnect=mysql_connect("localhost","root",""); mysql_select_db("emplo",$dbconnect); $eid=$_GET['eid']; $ename=$_GET['ename']; $esalary=$_GET['esalary']; //$get_select=mysql_query("select * from emp") or die("I cannot select Because".mysql_error()); $edit=$_POST['edit']; $delete=$_GET['delete']; if($edit=='UPDATE') { $edit=mysql_query("UPDATE emp SET eid='$eid',ename='$ename',esalary='$esalary' where eid='$eid'")or die(mysql_error()); //header("Location:empview.php"); } elseif($delete=='DELETE') { $delete=mysql_query("delete from emp where eid ='$eid'")or die(mysql_error()); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>empupdate</title> </head> <body> <div align="center"> <form id="form1" name="form1" method="post" action="empview.php"> <table width="438" height="183" border="1" cellpadding="1" cellspacing="1"> <tr> <td height="43" colspan="2" align="center">EMP DETAILS Updated </td> </tr> <tr> <td width="121">Emp Id </td> <td width="242"> <input name="eid" type="text" id="eid" value="<?php echo $eid; ?>" /></td> </tr> <tr> <td>Emp Name </td> <td><input name="ename" type="text" id="ename" width="200" value="<?php echo $ename; ?>" /></td> </tr> <tr> <td>Emp Salary </td> <td><input name="esalary" type="text" id="esalary" width="200" value="<?php echo $esalary; ?>"/></td> </tr> <tr> <td colspan="2" align="center"> <input name="btn_insert" type="submit" id="btn_insert" value="INSERT" /> <input name="btn_update" type="submit" id="btn_update" value="UPDATE" /> <input name="btn_display" type="submit" id="btn_display" value="DISPLAY" /> <input name="btn_delete" type="submit" id="btn_delete" value="DELETE" /> <input name="submit" type="submit" value="CLEAR" /></td> </tr> </table> </form> </div> </body> </html>
i dont know what exact problem in code but you using post method in form than how you will get the $_GET .use $_REQUEST array instead of both(post or get).