views:

188

answers:

4

Ok I have a PostgreSQL server with a Database titled brittains_db that I only have PuTTY access to. I can also upload via FTP to the web server which has access to PostgreSQL and the Database somehow...

I have made a SQL file named logins.sql

CREATE TABLE logins(
    userName VARCHAR(25) NOT NULL PRIMARY KEY,
    password VARCHAR(25) NOT NULL,
    firstName NOT NULL,
    lastName NOT NULL,
    ageDay INTEGER NOT NULL,
    ageMonth INTEGER NOT NULL,
    ageYear INTEGER NOT NULL,
    email VARCHAR(255) NOT NULL,
    createDate DATE
)

Then I made a form to get all that information.

<form action="<?php echo $_SERVER['PHP_SELF'];  ?>" method="post" >
    <table>
        <tr>
            <td class="signupTd">
                First Name:&nbsp;
            </td>
            <td>
                <input type="text" name="firstNameSignupForm" value="<?php echo $firstNameSignup; ?>" size="20"/>
            </td>
            <td>
                <?php echo $firstNameSignupError; ?>
            </td>
        </tr>
... code continues

I had it save all the information in variables if page run on POST

$firstNameSignup=trim($_POST["firstNameSignupForm"]);
$lastNameSignup=trim($_POST["lastNameSignupForm"]);
$userNameSignup=trim($_POST["userNameSignupForm"]);
$passwordSignup=trim($_POST["passwordSignupForm"]);
$passwordConfirmSignup=trim($_POST["passwordConfirmSignupForm"]);
$monthSignup=trim($_POST["monthSignupForm"]);
$daySignup=trim($_POST["daySignupForm"]);
$yearSignup=trim($_POST["yearSignupForm"]);
$emailSignup=trim($_POST["emailSignupForm"]);
$emailConfirmSignup=trim($_POST["emailConfirmSignupForm"]);

All information was then validated Now comes the points where I need to upload it to PostgreSQL

How do I put my table in Postgre? How do I insert my information into my table?

and how would I recall that information to display it?

+1  A: 

You need to use either use raw database functions or an abstraction library. An abstraction library should be considered because this will allow your code to be a little more portable and maintainable. Doctrine is a pretty good ORM library and there are several others available, depending on your needs.

For raw database functions (not recommended), I'd recommend PDO, if available. http://www.php.net/manual/en/pdo.prepared-statements.php

Michael Dean
+1  A: 

Start with the manual and take a look at pg_query_params(). Easy to use, safe and straight forward.

Frank Heikens
not sure how that works...
MrEnder
A: 

Or use PHP Data Object API to avoid postgreSQL-specific function calls

Benoit
A: 

First, be sure that you have thr php drivrs for postgres avaiable; Create a file with inside:

<?php
phpinfo();
?>

And check if pgsql is avaiable.

Then, you have just to choose your path:

  1. You can use the pg_* functions avaiable in php;
  2. You can use PDO, using the pgsql driver (look into the phpinfo if PDO is installed and enabled!);
  3. If you need an ORM, as other suggested, take a look at doctrine or propel, or just goole for 'php orm' and have fun
DaNieL