Location: PHPKode > projects > AWebNews > index.php
<?php
session_start();
// This script was developed by Adam M. B. from aWeb Labs
// Visit us at http://www.labs.aweb.com.au
// for forum problems, bugs, or ideas email hide@address.com
// thanks for trying out or using this news script
include "config.php";
$user123=$_POST['Username'];
$db = mysql_connect($db_host,$db_user,$db_pass); 
mysql_select_db ($db_name) or die ("Cannot connect to database"); 
//Get the data
$query = "SELECT id, username, password FROM users WHERE username='$user123'"; 
 
$result = mysql_query($query); 
/* Here we fetch the result as an array */ 
while($r=mysql_fetch_array($result)) 
{ 
/* This bit sets our data from each row as variables, to make it easier to display */ 
$id=$r["id"]; 
$_Username=$r["username"]; 
$_Password=$r["password"]; 


// If the form was submitted
if ($_POST['Submitted'] == "True") {

    // If the username and password match up, then continue...
    if ($_POST['Username'] == $_Username && $_POST['Password'] == $_Password) {

        // Username and password matched, set them as logged in and set the
        // Username to a session variable.
        $_SESSION['Logged_In'] = "486689";
        $_SESSION['Username'] = $_Username;
    }
}
} 
// If they are NOT logged in then show the form to login...
if ($_SESSION['Logged_In'] != "486689") {
    echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=login.php?page=" . $_SERVER['PHP_SELF'] . "\">";

}
else
{
include "style.php";
include "header.php";

$query7="SELECT * FROM comments";
$result7 = mysql_query($query7);
$commentsnum = mysql_num_rows($result7);
$query6="SELECT * FROM news";
$result6 = mysql_query($query6);
$newsnum = mysql_num_rows($result6);
$query5="SELECT * FROM categories";
$result5 = mysql_query($query5);
$catsnum = mysql_num_rows($result5);
?>
<div align="center"><div class="bluein-box3">
<b>Welcome to aWebNews, a news and comment management system.</b><br><br>
<b>Statistics:</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;<?=$commentsnum;?> Comments<br>
&nbsp;&nbsp;&nbsp;&nbsp;<?=$newsnum;?> News Articles<br>
&nbsp;&nbsp;&nbsp;&nbsp;<?=$catsnum;?> Categories<br><br>
</div></div>
<?
 
?><div align="center"><div class="bluein-box3">
<b>How to place news on your page:</b><br><br>
Change the page extension to '.php' and insert the following code where you want to news to appear:<br><br>
<font face="arial">
&lt;?php<br><font face="arial" color="green">
// Specify a category or leave empty to display all news articles</font><br>
<font face="arial" color="blue">$news_category</font> = <font face="arial" color="darkred">""</font>;<br><font face="arial" color="green">
// Path to news directory in relation to page displaying the news</font><br>
<font face="arial" color="blue">$path_to_news</font> = <font face="arial" color="darkred">"news/"</font>;<br><font face="arial" color="green">
// Location of news page in relation to page displaying the news (visview.php)</font><br>
<font face="arial" color="darkblue">include</font> <font face="arial" color="darkred">"news/visview.php"</font>;<br>
?&gt;
</font>
<br><br><b>How to place a listing of headlines on your page:</b><br><br>
Change the page extension to '.php' and insert the following code where you want to news to appear:<br><br>
<font face="arial">
&lt;?php<br><font face="arial" color="green">
// Specify a category or leave empty to display all news articles</font><br>
<font face="arial" color="blue">$listing_category</font> = <font face="arial" color="darkred">""</font>;<br><font face="arial" color="green">
// Path to news directory in relation to page displaying the news</font><br>
<font face="arial" color="blue">$path_to_news</font> = <font face="arial" color="darkred">"news/"</font>;<br><font face="arial" color="green">
// The page which includes visview.php (the headlines will link to this page)</font><br>
<font face="arial" color="blue">$path_to_page</font> = <font face="arial" color="darkred">"index.php"</font>;<br>
<font face="arial" color="green">
// Location of news page in relation to page displaying the news (listing.php)</font><br>
<font face="arial" color="darkblue">include</font> <font face="arial" color="darkred">"news/listing.php"</font>;<br>
?&gt;
</font>
<br><br>
</div>
<div class="bluein-box3">
<b>aWebNews Details:</b><br /><br />
&nbsp;&nbsp;&nbsp;&nbsp;Version: 1.5<br />
&nbsp;&nbsp;&nbsp;&nbsp;Developers Site: <a href="http://labs.aweb.com.au/" target="_blank">aWeb Labs</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;Project Site: <a href="http://labs.aweb.com.au/awebnews.php" target="_blank">aWebNews</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;Feedback: <a href="mailto:hide@address.com">aWeb Labs Projects</a><br /><br />
</div>
</div>
<?
include "footer.php";
}
// If they want to logout then
if ($_GET['mode'] == "logout") {
    // Start the session
    session_start();

    // Put all the session variables into an array
    $_SESSION = array();

    // and finally remove all the session variables
    session_destroy();

    // Redirect to show results..
    echo "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=" . $_SERVER['PHP_SELF'] . "\">";
}
mysql_close($db); 

?> 
Return current item: AWebNews