What I'm aiming for is the information (first name, last name, username and password) to be enetered into my PHP form and this information is then stored in the psql database (already created). This information can then be used later on on the log in page (yet to be created).
The first half of my script is running fine. The form displays and the user can enter the information. Once the submission form is hit this error appears:
Warning: pg_query() [function.pg-query]: Query failed: ERROR: function password("unknown") does not exist in /home2/webusers/07/344740/public_html/sporticket/reg.php on line 17
Could not execute query
As i said im new to PHP so if anyone is kind enough to explain what the error is can they please be explicit when explaining I'd appreciate it. Here is my script.
<html>
<head><title> Register </title></head>
<body>
<?php
if(isset($_POST['first_name'])){
$first_name = pg_escape_string($_POST['first_name']);
$last_name = pg_escape_string($_POST['last_name']);
$username = pg_escape_string($_POST['username']);
$password = pg_escape_string($_POST['password']);
if ( ( !$first_name ) or (!$last_name) or (!$username) or (!$password) ){
die("Missing some values");
}
$conn = @pg_connect("connection details hidden");
$psql = "INSERT INTO users(first_name,last_name,username,password) VALUES ('$first_name','$last_name','$username',password('$password'))";
$result = pg_query($psql) or die ("Could not execute query");
if ( $result ) {
echo "Congratulations, You can now log into Sporticket with the username and password you supplied";
} else {
echo "Failed to add user";
}
}else{
$form ="Please enter your details below to register with Sporticket";
$form.="<form action=\"\"";
$form.=" method=\"post\"> First Name: ";
$form.="<input type=\"text\" name=\"first_name\"";
$form.=" <br>Last Name: ";
$form.="<input type=\"text\" name=\"last_name\"";
$form.=" <br>Username: ";
$form.=" <input type=\"text\" name=\"username\"";
$form.=" <br>Password: ";
$form.=" <input type=\"text\" name=\"password\"";
$form.=" <br>";
$form.=" <input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo $form;
}
?>
</body>
</html>
It may need to be said that I'm not using MySql, but using to putty to access my psql. Also I'm limited to PHP 5
If anyone could be kind enough to have a look, I'd be very greatful.


Sign In
Create Account


Back to top









