<?php session_start(); ?> <html> <head> <style type="text/css" media="all"> @import "css/stylemaster.css"; </style> <title>Online Examination</title> </head> <body> <div id="page-container"> <div id="header"><h1> </h1> </div> <div id="main-nav">Main Nav</div> <div id="sidebar-a" > <font class="ws8" color="#FF9900" face="Tahoma"></font> <?php echo "Welcome $_SESSION[$username]"; ?> </div> <div id="content">Content Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam gravida enim ut risus. Praesent sapien purus, ultrices a, varius ac, suscipit ut, enim. Maecenas in lectus. Donec in sapien in nibh rutrum gravida. Sed ut mauris. Fusce malesuada enim vitae lacus euismod vulputate. Nullam rhoncus mauris ac metus. Maecenas vulputate aliquam odio. Duis scelerisque justo a pede. Nam augue lorem, semper at, porta eget, placerat eget, purus. Suspendisse mattis nunc vestibulum ligula. In hac habitasse platea dictumst. <h2>About</h2> <p><strong>Enlighten Designs</strong> is an Internet solutions provider that specialises in front and back end development. To view some of the web sites we have created view our portfolio.</p> <p>We are currently undergoing a 'face lift', so if you have any questions or would like more information about the services we provide please feel free to contact us.</p> <h2>Contact Us</h2> <p>Phone: (07) 853 6060<br /> Fax: (07) 853 6060<br /> Email: <a href="mailto:info@enlighten.co.nz">info@enlighten.co.nz</a><br /> P.O Box: 14159, Hamilton, New Zealand</p> <p><a href="#">More contact information...</a></p> </div> <div id="footer"><div id="altnav"> <a href="#">About</a> - <a href="#">Services</a> - <a href="#">Portfolio</a> - <a href="#">Contact Us</a> - <a href="#">Terms of Trade</a> </div> Copyright © Enlighten Designs <br/> Powered by <a href="http://www.enlightenhosting.com/">Enlighten Hosting</a> and <a href="http://www.vadmin.co.nz/">Vadmin 3.0 CMS</a> </div> </div> </body> </html>
HERE IS MY LOGIN.PHP
<?php
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection= @mysql_connect($db_host,$db_user,$db_password) or die("Error Connecting");
mysql_select_db($db_name,$connection);
if (isset($_POST["username"]) && isset($_POST["password"]))
{
$username = mysql_real_escape_string($_POST["username"]);
$password = mysql_real_escape_string($_POST["password"]);
$query = "SELECT * FROM login WHERE Username='$username' and Password='$password'";
echo ($query);
$results = mysql_query($query);if(mysql_num_rows($results) == 1)
{
$_SESSION['username'] = $_REQUEST['username'];
header("Location: home.php");
}
else
{
echo '<script type=""text/javascript""> alert("Access Denied! Incorrect Username or Password") </script>';
}
}
?>
<head>
<style type="text/css" media="all">
@import "css/stylemaster.css";.style1 {font-size: 10px}
.style3 {font-size: 10px; font-weight: bold; }
.style4 {color: #FFFFFF}
body {
background-color: #FFFFFF;
}
</style>
</head>
<body>
<div id="page-container">
<div id="header"><h1> </h1>
</div>
<div id="main-nav">Main Nav</div>
<div id="sidebar-a">
<form id="form1" name="form1" method="post" action="home.php">
<h3 class="style1">>> Login </h3>
<pre>User Type : <select name="usertype" size="1" id="usertype"> <option selected="selected">Student</option> <option>Lectuerer</option> <option>Administrator</option> </select>
</pre>
<pre>User Name: <input name="username" type="text" id="username" value="" size="12px" />
</pre>
<pre>Password : <input type="password" name="password" id="password" size="12px"/>
</pre>
<pre> <input type="submit" name="Login" value="Submit" />
</pre>
<p>Not a member yet?<br>
<a href="register.php">Register Now!</a></p>
<p> </p>
</form>
</div>
</body>
WHEN I LOGGED IN USING A USERNAME. I WANT THAT USERNAME TO SHOW IN MY HOME PAGE. PLS HELP ME SOMONE
AT THIS TIME THE ERROR IS
Notice: Undefined variable: username in C:\wamp\www\home.php on line 25

New Topic/Question
Reply




MultiQuote






|