Hey guys I need help creating a PHP function/statement to update a record in my database and also one to delete a record from the database.
I already got the add record to the database working.
HTML FORM CODE
HTML Code:<head> <title>Change Person</title> </head> <body> <form action="change_person.php"> ID: <input type="text" name="id" /> Name: <input type="text" name="name" /> Gender: <input type="text" name="gender" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body>HTML Code:<head> <title>Add Person</title> </head> <body> <form action="add_person.php"> ID: <input type="text" name="id" /> Name: <input type="text" name="name" /> Gender: <input type="text" name="gender" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body>
PHP CODE ADD PERSON
I messed around trying to get the delete and update function working but not getting anywhere. Can anyone provide some help.PHP Code:
<HTML>
<HEAD>
<TITLE> Add Person</TITLE>
</HEAD>
<BODY>
<?php
include('connect.php');
$id=$_GET['id'];
$name=$_GET['name'];
$gender=$_GET['gender'];
$age=$_GET['age'];
$query="INSERT INTO person (id,Name,Gender,Age) VALUES ('$id','$name','$gender','$age')";
if(pg_query($query)) {
echo "User successfully added";
}
else {
echo " ERROR: Duplicate Person";
}
?>
</BODY>
</HTML>