I had made a persons profile in a html page and stored the data in a postgre database. Now I want that, when the person visit his profile page only that person should be able to update the profile and data should be update in the database. And when he go to the editable mode data should be fetched from database and when he update the profile database should also be updated.
how to update a table in a database by a html form
Collapse
X
-
First you must have established some level of authority in your db. Meaning that, after a user has logged in and been succesfully verified, you can tie that (unique) login userdata to only one unique profile (set of) record(s) only. Such as [php]SELECT * from profile_table WHERE userid='$login_ data' .... ;[/php]
The same applies to all operations on that data, like INSERT and UPDATE. Always verify that such an operation on that particular data can only be performed by the verified user.
Ronald :cool: -
how to give login and password to a table in pgsql database? and after that how can I fetch the data from that table and display it in a html form so that the client can edit it and the edited information is update in the database.Originally posted by ronverdonkFirst you must have established some level of authority in your db. Meaning that, after a user has logged in and been succesfully verified, you can tie that (unique) login userdata to only one unique profile (set of) record(s) only. Such as [php]SELECT * from profile_table WHERE userid='$login_ data' .... ;[/php]
The same applies to all operations on that data, like INSERT and UPDATE. Always verify that such an operation on that particular data can only be performed by the verified user.
Ronald :cool:Comment
-
Show us what code you have developed until now and we will see how we can help you out. (don't forget to enclose that code within the appropriate code, html or php tags!! See the Posting Guidelines).
Ronald :cool:Comment
-
I had made a html file that is:Originally posted by ronverdonkShow us what code you have developed until now and we will see how we can help you out. (don't forget to enclose that code within the appropriate code, html or php tags!! See the Posting Guidelines).
Ronald :cool:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitl ed Document</title>
<html>
<body>
<form action="add.php " method="post">
First Name : <input type="text" name="firstname " size="40" length="40" value="First Name"><BR>
Surname : <input type="text" name="surname" size="40" length="40" value="Surname" ><BR>
Email Address : <input type="text" name="emailaddr ess" size="40" length="40" value="Email Address"><BR>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Clear It">
</form>
</body>
</html> [/HTML]
and my add.php goes like this:
[PHP]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$db = pg_connect('hos t=172.28.44.75 dbname=personal user=postgres password=');
$firstname = pg_escape_strin g($_POST['firstname']);
$surname = pg_escape_strin g($_POST['surname']);
$emailaddress = pg_escape_strin g($_POST['emailaddress']);
$query = "INSERT INTO friends(firstna me,surname,emai laddress) VALUES('" . $firstname . "', '" . $surname . "', '" . $emailaddress . "')";
$result = pg_query($query );
if (!$result) {
$errormessage=p g_last_error();
echo "Error with query: " . $errormessage;
exit();
}
printf ("These values were inserted into the database - %s %s %s", $firstname, $surname, $emailaddress);
pg_close();
?>
</body>
</html>[/PHP]
but after running this program I got an error that is:
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Warning: Unable to connect to PostgreSQL server: No pg_hba.conf entry for host 172.28.44.75, user postgres, database personal in /web/train06/myphp/add.php on line 11
Fatal error: Call to undefined function: pg_escape_strin g() in /web/train06/myphp/add.php on line 13
can u tell me that where i am going wrong.Comment
Comment