cannot connect with database
Posted: Wed Jun 03, 2009 2:01 pm
//first.html//
<html>
<body>
<form action="one.php" method="post">
First name: <input type="text" name="FirstName" size="20" /><br />
Last name: <input type="password" name="password" size="20" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
//one.php//
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db1", $con);
$sql="INSERT INTO info (username,password)
VALUES
('$_POST[FirstName]','$_POST[password]')";
header("Location: second.html");
?>
//there is an error when run in browser-:
Could not connect: Access denied for user 'root'@'localhost' (using password: NO)//
<html>
<body>
<form action="one.php" method="post">
First name: <input type="text" name="FirstName" size="20" /><br />
Last name: <input type="password" name="password" size="20" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
//one.php//
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db1", $con);
$sql="INSERT INTO info (username,password)
VALUES
('$_POST[FirstName]','$_POST[password]')";
header("Location: second.html");
?>
//there is an error when run in browser-:
Could not connect: Access denied for user 'root'@'localhost' (using password: NO)//