Hi everyBody,
Iam having a problem in the login..Tell me please what is the wrong. Is it in DB or PHP code?
DB:[code=sql]
-- Host: localhost
-- Generation Time: May 10, 2008 at 08:50 PM
-- Server version: 3.23.52
-- PHP Version: 4.2.3
--
-- Database: `school`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`user` varchar(20) NOT NULL default '',
`password` varchar(30) NOT NULL default '',
PRIMARY KEY (`user`)
) TYPE=MyISAM;
--
-- Dumping data for table `users`
--
INSERT INTO `users` VALUES ('sh', '123456');
INSERT INTO `users` VALUES ('Fatima', '123456');[/code]
[php]<html>
<body>
<?
$con = mysql_connect(" localhost","", "");
if (!$con) {
die('Could not connect ');
}
mysql_select_db ("school", $con);
$sql="SELECT user,password FROM users WHERE user='$_POST[username]' AND password = '$_POST[password]'";
$result = mysql_query($sq l);
$row=mysql_fetc h_array($result );
if($row[0] == "") {
die('<h1>Wrong username or password..Pleas e insert the correct one..');
} else{
session_start() ;
$_SESSION['username'] = $_POST['username'];
$_SESSION['passward'] = $row[0];
header("Locatio n:Teacher buttons.htm");
}
mysql_close($co n);
?>
</body>
</html>[/php]please Can you help me??
Iam having a problem in the login..Tell me please what is the wrong. Is it in DB or PHP code?
DB:[code=sql]
-- Host: localhost
-- Generation Time: May 10, 2008 at 08:50 PM
-- Server version: 3.23.52
-- PHP Version: 4.2.3
--
-- Database: `school`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`user` varchar(20) NOT NULL default '',
`password` varchar(30) NOT NULL default '',
PRIMARY KEY (`user`)
) TYPE=MyISAM;
--
-- Dumping data for table `users`
--
INSERT INTO `users` VALUES ('sh', '123456');
INSERT INTO `users` VALUES ('Fatima', '123456');[/code]
[php]<html>
<body>
<?
$con = mysql_connect(" localhost","", "");
if (!$con) {
die('Could not connect ');
}
mysql_select_db ("school", $con);
$sql="SELECT user,password FROM users WHERE user='$_POST[username]' AND password = '$_POST[password]'";
$result = mysql_query($sq l);
$row=mysql_fetc h_array($result );
if($row[0] == "") {
die('<h1>Wrong username or password..Pleas e insert the correct one..');
} else{
session_start() ;
$_SESSION['username'] = $_POST['username'];
$_SESSION['passward'] = $row[0];
header("Locatio n:Teacher buttons.htm");
}
mysql_close($co n);
?>
</body>
</html>[/php]please Can you help me??
Comment