Location: PHPKode > projects > MyNews > mynews/install.php
<?php
// ----------------------------------------------------------------------
// MyNews
// Copyright (C) 2004 by Frank Mancuso Aka crash4o4
// https://sourceforge.net/projects/mynews/
// http://frankmancuso.ca
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Frank Mancuso aka crash4o4
// Purpose of file:
// ----------------------------------------------------------------------


// If form is submitted proceed to install
$request = $_SERVER['REQUEST_METHOD'];

if ( $request == "POST" )
{

	$username	= $_POST['username'];
	$pass		= $_POST['passwd'];
	$email		= $_POST['email'];
	$passwd		= md5($pass);
	
	// Create database tables starts here //
	include("config.php");
	include("mysql.php");
	// class mysql class
	$db2 = new db;
	// replace varibles
	$db2->info['sql_host'] = $conf['sql_host'];
	$db2->info['sql_user'] = $conf['sql_user'];
	$db2->info['sql_pass'] = $conf['sql_pass'];
	$db2->info['sql_db']   = $conf['sql_db'];
	
	$db2->connect();
	
	// Create Tables
	$sql = "
	CREATE TABLE users(
	user_id INT PRIMARY KEY AUTO_INCREMENT,
	username VARCHAR(40) NOT NULL,
	password VARCHAR(255) NOT NULL,
	email VARCHAR(75) NOT NULL,
	group_id VARCHAR(10) DEFAULT 'Writter'
	)
	";
	
	$db2->query($sql);
	
	echo "<p>Table users <b>Created</b></p>";
	
	$sql2 = "
	CREATE TABLE sessions(
	row_id INT PRIMARY KEY AUTO_INCREMENT,
	username VARCHAR(40) NOT NULL,
	password VARCHAR(255) NOT NULL,
	session_key VARCHAR(255) NOT NULL,
	ip_address VARCHAR(25) NOT NULL,
	group_id VARCHAR(10) NOT NULL
	)
	";
	
	$db2->query($sql2);
	
	echo "<p>Table sessions <b>Created</b></p>";
	
	$sql3 = "
	CREATE TABLE mynews_news(
	news_id INT PRIMARY KEY AUTO_INCREMENT,
	News_Title VARCHAR(255) NOT NULL,
	News_Body LONGTEXT NOT NULL,
	News_Body_Extend LONGTEXT,
	Post_Date DATETIME,
	Posted_By VARCHAR(40),
	Active VARCHAR(1) DEFAULT '0'
	)
	";
	
	$db2->query($sql3);
	echo "<p>Table mynews_news <b>Created</b></p>";
	
	// Create database tables ends here //
	
	// Add Admin User
	$sql4 = "INSERT INTO users SET username='$username',password='$passwd',email='$email',group_id='Admin' ";
	$db2->query($sql4);
	echo "<p>Admin user <b>$username</b> has been added</p>";
	echo "Remove install.php file and then <a href=\"login.php\">login</a>";
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyNews</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="default.css">
</head>

<body>

<h1>MyNews</h1>
<h3>Install Check List</h3>


<form action="install.php" method="POST">
<table width="550" border="0" cellspacing="0" cellpadding="3">
  
  <tr>
    <td>&nbsp;</td>
    <td><b>Admin Information</b> </td>
  </tr>
  <tr>
    <td>Username</td>
    <td>
      <input type="text" name="username" />
    </td>
  </tr>
  <tr>
    <td>Password</td>
    <td>
      <input type="text" name="passwd" />
    </td>
  </tr>
  <tr>
    <td>Email</td>
    <td>
      <input type="text" name="email" />
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="submit" value="Install" />
    </td>
  </tr>
</table>
</form>

<p>&nbsp;</p>

<p><img src="images/php.png" border="0" alt="Powered By PHP" />&nbsp;<img src="images/mysql.png" border="0" alt="Powered By MySQL" /></p>
</body>
</html>
Return current item: MyNews