i have index.php, login.php, connection.php and welcome.php that i can't find where is the error between of them. and all of this is for login issue that i want to login but suddenly i can't login that i want to show the words WELCOME please take a look a code below.
index
Code: Select all
<html>
<body>
<table border = "0" bgcolor = "#ffffff" cellpadding = "2" cellspacing = "3" align = "center">
<form action="login.php" method="post">
<tr>
<td>Firstname: </td>
<td><input type="text" name="uname" /></td>
</tr>
<tr>
<td>Lastname: </td>
<td><input type="text" name="pwd" /></td>
</tr>
<tr>
<td colspan = "2" align = "center"><input type="submit" /></td></tr>
</form></table>
</body>
</html>
Code: Select all
<?php
include("connection.php");
mysql_select_db("mydatabase");
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$uname = stripslashes($uname);
$pwd = stripslashes($pwd);
$uname = mysql_real_escape_string($uname);
$pwd = mysql_real_escape_string($pwd);
$sql = SELECT * FROM $tbl_login WHERE uname = '$uname', and pwd = '$pwd';
$result = mysql_query($sql);
$count = mysql_num_rows($result());
if($count == 1)
{
session_register("uname");
session_register("pwd");
header("location: welcome.php");
}
else
echo "Please login again";
?>
Code: Select all
<?php
$con = mysql_connect("localhost","root","jayson");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>Code: Select all
<?php
session_start();
if(!session_register(uname))
{
header(location: login.php);
}
?>
<html>
<body>
WELCOME
</body>
</html>