Location: PHPKode > scripts > Coopercentral Login > Coopercentral_Login_2.0/members/install.php

/* Coopercentral Login 2.0 installation page
   Please fill out these fields to create the
   necessary tables
// check if user is logged in
echo "<font size=\"5\"><b>Coopercentral Login 2.0</b></font><br>
<font size=\"+1\"><b>Installation Page</b></font><p>";

if(!isset($_POST[submit])) {

		echo "Please make certain your database settings are correct below to create the needed tables.<p>
		<form method=\"POST\" action=\"".$_SERVER[PHP_SELF]."\">
			<td>DB Hostname</td>
			<td><input type=\"text\" name=\"database_host\" value=\"$db_host\"></td>
			<td>DB Username</td>
			<td><input type=\"text\" name=\"database_user\" value=\"$db_user\"></td>
			<td>DB Password</td>
			<td><input type=\"text\" name=\"database_pass\" value=\"$db_pass\"></td>
			<td>DB Name</td>
			<td><input type=\"text\" name=\"database_name\" value=\"$db_name\"></td>
		    <td colspan=2>&nbsp;</td>
		    <td>Administrator Username</td>
			<td><input type=\"text\" name=\"admin_user\"></td>
		    <td>Administrator Password</td>
			<td><input type=\"password\" name=\"admin_pass\"></td>
			<td colspan=2><input type=submit name=submit value=submit></td>

} else if(isset($_POST[submit])) {

	if((empty($_POST[admin_user]) or empty($_POST[admin_pass])) || (strlen($_POST[admin_pass]) < 8)) {

		echo "<font color=\"red\"><b>Make sure you entered a valid Administrator username/password, and that the password is at least 8 characters</b></font>";

	} else {

		@mysql_connect($_POST[database_host], $_POST[database_user], $_POST[database_pass]) or die("Invalid SQL settings, please try again");
		@mysql_select_db($_POST[database_name]) or die("Invalid database name, please try again");

		$sql = "CREATE TABLE IF NOT EXISTS `$users_table` (
				  `id` int(11) NOT NULL AUTO_INCREMENT,
				  `username` varchar(35) NOT NULL,
				  `password` varchar(35) NOT NULL,
				  `fname` varchar(35) NOT NULL,
				  `lname` varchar(35) NOT NULL,
				  `email` varchar(55) NOT NULL,
				  `priv` int(11) NOT NULL,
				  `time` varchar(20) NOT NULL,
				  PRIMARY KEY (`id`)

		@mysql_query($sql) or die("Could not execute table creation.  Please check your database settings.");

		$result = mysql_query("INSERT INTO users VALUES ('1','".$_POST[admin_user]."','".md5($_POST[admin_pass])."','Administrator','N/A','".$_SERVER[SERVER_ADMIN]."','10','".time()."')");

		echo "<font size=\"+1\"><b>Successful!</b></font><p>
				You successfully installed the required tables.  Please delete this file (install.php) via FTP or file manager for security reasons.";


Return current item: Coopercentral Login