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.