Hello,
I am a student who has a Intranet site as my project to build, in fact I have been on with this for about a year :o
I originally built the site using html in Dreamweaver great no problem, but then came the bug bear to my problem. I found out to make a good secure log in system I needed to use php along with MySql, either of which I have never touched on and my tutor who gave me the project has never used either.
So I bought some books to try and teach myself used many websites that are out there and feel no further forward. In face got so fed up from August till January I didn't even touch it.
I have stripped it down and rebuilt it so many times. This is my current Index.php page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>intranet</title>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
color: #000000;
}
.style2 {font-size: 36px}
-->
</style>
<link href="*" rel="stylesheet" type="text/css" />
<link href="style1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {
color: #FFFFFF
}
-->
</style>
<link href="*" rel="stylesheet" type="text/css" />
<link href="style1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="background"></div>
<div id="container">
<div id="Banner"></div>
<div id="navbar">Globel IT News
<script language="JavaScript" src="http://www.feedbucket.com/js.php?src=http%3A%2F%2Fwww.theregister.co.uk%2Fscience%2Frotm%2Fheadlines.atom&chan=y&desc=1&date=y" type="text/javascript"></script></div>
<div class="style3" id="announcement">College Announcments and Pupil Achievments</div>
<div id="text">
<h3 align="center" class="style1 style2">Welcome To</h3>
<p align="center" class="style1 style2">Darlington College and Teesside University</p>
<p align="center" class="style1 style2">School of Computing</p>
<h3 align="center" class="style1 style2">Our Future Is In Your Hands</h3>
<p> </p>
<p> </p>
<p> </p>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php
//allow sessions to be passed so we can see if the user is logged in
session_start();
//connect to the database so we can check, edit, or insert data to our users table
$dbname = 'a6346544_phplog';
$con = mysql_connect("mysql13.**********.com","user","pass") or die(mysql_error());
$db = mysql_select_db($dbname, $con) or die(mysql_error());
//include out functions file giving us access to the protect() function
include "./functions.php";
//If the user has submitted the form
if($_POST['submit']){
//protect the posted value then store them to variables
$username = protect($_POST['username']);
$password = protect($_POST['password']);
//Check if the username or password boxes were not filled in
if(!$username || !$password){
//if not display an error message
echo "<center>You need to fill in a <b>Username</b> and a <b>Password</b>!</center>";
}else{
//if the were continue checking
//select all rows from the table where the username matches the one entered by the user
$res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'");
$num = mysql_num_rows($res);
//check if there was not a match
if($num == 0){
//if not display an error message
echo "<center>The <b>Username</b> you supplied does not exist!</center>";
}else{
//if there was a match continue checking
//select all rows where the username and password match the ones submitted by the user
$res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."' AND `password` = '".$password."'");
$num = mysql_num_rows($res);
//check if there was not a match
if($num == 0){
//if not display error message
echo "<center>The <b>Password</b> you supplied does not match the one for that username!</center>";
}else{
//if there was continue checking
//redirect them to the usersonline page
if ($YearofStudy=="Year 1")
{
header("location: 1st Year.php");
}
else
{
header("location: Year2Homepage.php");
//split all fields fom the correct row into an associative array
$row = mysql_fetch_assoc($res);
//check to see if the user has not activated their account yet
if($row['active'] != 1){
//if not display error message
echo "<center>You have not yet <b>Activated</b> your account!</center>";
}else{
//if they have log them in
//set the login session storing there id - we use this to see if they are logged in or not
$_SESSION['uid'] = $row['id'];
//show message
echo "<center>You have successfully logged in!</center>";
//update the online field to 50 seconds into the future
$time = date('U')+50;
mysql_query("UPDATE `users` SET `online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'");
}
}
}
}
}
?>
<form action="index.php" method="post">
<div id="border">
<table cellpadding="2" cellspacing="0" border="0" align="center">
<tr>
<td>Username:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Login" /></td>
</tr>
<tr>
<td align="center" colspan="2"><a href="register.php">Register</a> | <a href="forgot.php">Forgot Pass</a></td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
</html>
I really don't no why this one won't even load up, in fact if somebody has a link to a built template I would love it.
This is the one I used to rebuild the site yesterday http://gigaspartan.com/2010/11/26/how-to-build-a-full-featured-login-system/