So, I just installed XAMPP on my PC running Windows 7. Here's what my website looks like:
/Header.php
<?php
session_start();
include("http://localhost/Functions.php");
connect();
?>
/Functions.php
<?php
function connect(){
$username = "dartz654";
$password = "letmein";
$hostname = "localhost";
$con = mysql_connect($hostname,$username,$password) or die ("Unable to connect");
mysql_select_db(database, $con);
}
?>
/My/Register.php
<?php
include("http://localhost/Header.php");
if(!$_POST['submit']){
echo "<form method=\"post\">";
echo "<input type=\"text\" name=\"username\">";
echo "<input type=\"password\" name=\"password\">";
echo "<input type=\"submit\" name=\"submit\" value=\"Register\">";
echo "</form>";
}else {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "INSERT INTO `users` (`username`,`password`) VALUES ('".$username."','".$password."')";
$res = mysql_query($sql) or die(mysql_error());
echo "You've registered.";
}
?>
When I hit 'register' on the register one, it'll show an error like this:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\My\Register.php on line 15
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\My\Register.php on line 15
Access denied for user 'ODBC'@'localhost' (using password: NO)
Help please?
P.S. If theres some error in my code, its probably just a mistake I made when cutting out code... The actual register is alot longer, I just took out the unimportant stuff. The real problem is the connection part...