Hi,
I'm trying to insert data to a PostgreSQL database, but somehow, the script won't do what I want to: the $submit check in the if-statement never yields true, so I always get the form as output.
I'm running postgresql version 7.3 and PHP 4.3.1 (register_globals is set to on! using $_POST doesn't help me)
This is my (pretty standard) script:
<html>
<head>
<title>Insert into Database</title>
</head>
<body>
<?php
$dbhandle = pg_connect("dbname=db user=user password=pass host=host port=port");
if ($submit) {
$sql = "INSERT INTO dbase(name) VALUES ('$name')";
pg_exec($dbhandle, $sql) or die("Couldn't Connect".pg_last_error());
echo "Database updated";
}
else {
?>
<FORM action="<?php echo $PHP_SELF; ?>" method="POST">
Name: <INPUT type="text" size="35" name="name"><BR>
<input type="submit" name="submit" value="Add">
</form>
<?php
}
pg_close($dbhandle);
?>
</body>
</html>
Who can help me?