473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

how to update a table in a database by a html form

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.
Jan 8 '07 #1
4 3001
ronverdonk
4,258 Expert 4TB
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:
Jan 8 '07 #2
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.
Jan 10 '07 #3
ronverdonk
4,258 Expert 4TB
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:
Jan 10 '07 #4
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:
I had made a html file that is:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled 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="emailaddress" 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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$db = pg_connect('host=172.28.44.75 dbname=personal user=postgres password=');

$firstname = pg_escape_string($_POST['firstname']);
$surname = pg_escape_string($_POST['surname']);
$emailaddress = pg_escape_string($_POST['emailaddress']);

$query = "INSERT INTO friends(firstname,surname,emailaddress) VALUES('" . $firstname . "', '" . $surname . "', '" . $emailaddress . "')";
$result = pg_query($query);
if (!$result) {
$errormessage=pg_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_string() in /web/train06/myphp/add.php on line 13

can u tell me that where i am going wrong.
Jan 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Fredrik/Sweden | last post by:
Hi folks ! got this problem... i have a table 'Accounts' in my database, which contains a bunch of users. From the main menu i choose "edit user" and all users in the db are presented in a table....
5
by: A.Dagostino | last post by:
hi i need to update an SQL Table when user select or unselect a checkbox control. How Can i do? Thanks Alex
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
5
by: cover | last post by:
I have an input form that passes data when submitted to a second form to let the user know what they have just entered into the db. My question comes with using 'update'. I'd like to query the...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.