d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Php Help...
Add Reply New Topic New Poll
Member
Posts: 1,144
Joined: Jul 25 2012
Gold: 0.00
Oct 21 2012 04:52pm
I need to create 2 pages...one is an index.php and the other is register.php...the index page is simply just a login page that accepts a username/password in text boxes with a submit button and checks with the database to see if this exists in the database....the registration page registers the user and stores their username/password into the database. The passwords must be hashed, then a salt added to the hash, then rehashed before being stored into the database....I'm fine with that part but how do you do the php to get the information to the database....I have the html built and I know the commands for the postgreSQL...but we haven't learned PHP so I'm utterly confused as to how to do this...
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 21 2012 05:05pm
http://php.net/manual/en/book.pgsql.php

you're welcome

This post was edited by carteblanche on Oct 21 2012 05:06pm
Member
Posts: 1,144
Joined: Jul 25 2012
Gold: 0.00
Oct 21 2012 05:11pm
I have no idea how to do any of this, it's pretty much "hey do this assignment using PHP that you haven't learned.. you have one week, goodluck!" I just don't understand the order to do this in PHP...how do I pull the information from the form, insert it into the Database then transfer them back to the home page?
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 21 2012 07:50pm
FROM CARTEBLANCHES LINK

Code

<?php
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
   or die('Could not connect: ' . pg_last_error());

// Performing SQL query
$query = 'SELECT * FROM authors';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());

// Printing results in HTML
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
   echo "\t<tr>\n";
   foreach ($line as $col_value) {
       echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
pg_free_result($result);

// Closing connection
pg_close($dbconn);
?>
Member
Posts: 827
Joined: Jan 16 2012
Gold: 0.00
Warn: 10%
Oct 22 2012 08:13am
spoon fed...
Member
Posts: 161,550
Joined: Oct 18 2006
Gold: 4.03
Warn: 20%
Oct 23 2012 06:32am
Quote (StormHasHe @ Oct 22 2012 07:13am)
spoon fed...


not really, that select chunk needs a good amount of edits
Member
Posts: 1,144
Joined: Jul 25 2012
Gold: 0.00
Oct 24 2012 03:49pm
I understand that part...but what I don't understand is how to fully interact with it... we have 3 tables in our .sql file...one with authentication that contains the username/salt/hashed password with a FK constraint on a user table that has username, registration date and description...then a log table that stores their IP and date/time they log into the site...

I'm just confused as to how to code the "login.php" page where it pulls the information from the form (username/pass) and then queries the database to pull the salt for the form's specified username then concatenate the salt + hashed password and rehash it then compare the hashed password to the hashed password in the authentication table for when they registered...

Cookies also must be activated so they are automatically logged into the site and sent via header(location: home.php) to their home page where it displays a table with their username: registration date: registration IP: description: then has another table that displays every single date: and it's IP from every log in they've had..
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Oct 25 2012 06:10am
Encrypting your code twice is stupid.
Just use a salt and pepper both encrypted then encrypt the whole string.

If you're that worried about security...

And for the login Page you'll want to be looking at sessions.
Member
Posts: 644
Joined: Oct 27 2012
Gold: 1,404.00
Oct 27 2012 07:47pm
This almost perfectly describes a small assignment one of my profs gave at the start of the semester for the web programming course I took. :lol:
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll