Using User data from forum databases for lists

L0s7 4 Lyf3

Limp Gawd
Joined
Mar 3, 2004
Messages
454
I want to make a PHP script that uses user registration data from mySQL forum databases so i can make a login form on one page, and when a user logs in from that form it adds that person to a list...

though i'm not all that familiar with PHP/mySQL but with a little help I should be able to scrape my ass by :D...

i want to do it like this
 
OK, so there's not really even a password. This is pretty straightforward.

I'll assume you can put together the HTML form with an input name of "user"

PHP would look something like

Code:
<?php
if (isset($_REQUEST["user"]) && (strlen($_REQUEST["user"]) > 0))
{  // this is a valid submission, add more logic if needed
  $sql = "INSERT INTO `users` (`user`) VALUES ('" . $_REQUEST["user"] . "')";
  $dbconn = mysql_connect(/*insert parameters*/);
  mysql_select_db(/*insert parameters*/);
  $success = mysql_query($sql, $dbconn);
  mysql_close($dbconn);

  // if $success is TRUE, process complete
  // if FALSE, you screwed up
}
?>

And the database, in this case, would be something like:
Code:
create table users (
	`user_id`      INT UNSIGNED NOT NULL auto_increment,
	`user`          VARCHAR(80),
        primary_key(`user_id`)
);

Finally, the display page would be along the lines of
Code:
<table>
  <thead><tr><th>Reg No</th><th>Name</th></tr></thead>
  <tfoot><tr style="height:0; line-height:0;"><td></td><td></td></tr></tbody>
  <tbody>
<?php
$db_connmysql_connect(/*as above*/);
mysql_select_db(/*as above*/);
$sql = "SELECT * FROM `users`";
$result = mysql_query($sql, $dbconn);
while($row = mysql_fetch_assoc($result))
{
  echo "    <tr><td>" . $row["user_id"] . "</td><td>" . $row["user"] . "</td></tr>\n";
}
mysql_close($db_conn);
?>
  </tbody>
</table>
 
Back
Top