Issue with “login.php” in Ubuntu for chat program in PHP

gribonn53

New Member
\[code\]<?php// variables$user = $_POST['user'];$ip = $_SERVER['REMOTE_ADDR'];// escape any malicious charactersif (!get_magic_quotes_gpc()){ $user = addslashes($user);}if (empty($user)){ echo "Please enter a username.";}else{ # connect to the database include_once('connection.php'); // database query $sql = mysql_query("INSERT INTO chat VALUES ('$user','joins the chat!',NULL,'$ip')"); mysql_close($link); // create cookie and redierct user to chat page setcookie("name",$user,time()+3600,"/"); header("Location:chat.html");}?>\[/code\]The code I'm using to connect to the DB is:\[code\]<?php// MySQL database connection file$SERVER = "127.0.0.1"; // MySQL SERVER$USER = "root"; // MySQL USER$PASSWORD = "admin"; // MySQL PASSWORD$link = @mysql_connect($SERVER,$USER,$PASSWORD);$db = mysql_select_db("website");?>\[/code\]Can anyone help me? This \[code\]login.php\[/code\] code is unable to connect to database.
 
Back
Top