Hello. I recently created a user registration script to be used with my website; however, when I run it I get a DB connect error. I was wondering if anyone would have any possible solutions.
Here is the main PhP registration script
<head>
<link rel="stylesheet" type="text/css" href="/layouts/mainlayout.css" media="screen" />
</head><?php
include("header.php");
php?>
<?php
$uname=$_POST['userid'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$mname=$_POST['mname'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$email=$_POST['email'];
$email2=$_POST['email2'];
$country=$_POST['country'];
$state=$_POST['state'];
$city=$_POST['city'];
$zip=$_POST['zip'];
$bday=$_POST['day'];
$bmonth=$_POST['month'];
$byear=$_POST['year'];
$sex=$_POST['sex'];
$agree=$_POST['agree'];
$ip=$_SERVER['REMOTE_ADDR'];
$status = "OK";
$msg="";
if (empty($_POST['userid'])) {
$msg=$msg. "You must enter a user name<br>";
$status = "NOTOK";
}
if (empty($_POST['fname'])){
$msg=$msg. "You must enter your first name.<br>";
$status = "NOTOK";
}
if (empty($_POST['lname'])){
$msg=$msg. "You must enter your last name<br>";
$status = "NOTOK";
}
if (empty($_POST['password'])){
$msg=$msg. "You must enter a password.<br>";
$status = "NOTOK";
}
if (empty($_POST['password2'])){
$msg=$msg. "You must re-enter your password.<br>";
$status = "NOTOK";
}
if (empty($_POST['email'])){
$msg=$msg. "You must enter your email.<br>";
$status = "NOTOK";
}
if (empty($_POST['email2'])){
$msg=$msg. "You must re-enter your email.<br>";
$status = "NOTOK";
}
if(!isset($uname) or strlen($uname) <4){
$msg=$msg."User name must be between 4 and 10 characters.<BR>";
$status= "NOTOK";}
if(!isset($uname) or strlen($uname) >10){
$msg=$msg."User name must be between 4 and 10 characters.<BR>";
$status= "NOTOK";}
if($password != $password2){
$msg=$msg. "Passwords do not match. Passwords must match. Try again<BR>";
$status="NOTOK";}
if($email != $email2){
$msg=$msg. "Emails do not match. Emails must match. Try again<BR>";
$status="NOTOK";}
if($_POST['agree'] != "yes"){
$msg=$msg. "You must agree to the terms and conditions";
$status= "NOTOK";
}
if(mysql_num_rows(mysql_query("SELECT UID FROM USERS WHERE UNICK = '$userid'"))){
$msg=$msg."User Name already exists. Please try another one<BR>";
$status= "NOTOK";}
if(mysql_num_rows(mysql_query("SELECT UID FROM USERS WHERE UEMAIL = '$email'"))){
$msg=$msg."The email provided has already been registered. Only one account per person.<BR>";
$status= "NOTOK";}
if ($status != "OK"){
echo "<div style=\"position:relative; top:0; left:0; width:500; height:500; z-index:1;\">$msg<form>
<input type=\"button\" value=\"Back to Previous Page\"
onClick=\"javascript: history.go(-1)\">
</form></div>";
}else{
$activation = md5(uniqid(rand(), true));
$password = md5($password);
if(mysql_query("insert into USERS(UID,UFNAME,UMNAME,ULNAME,UNICK,UGENDER,UPW,UEMAIL,UBDAY,UBMONTH,UBYEAR,UIP,UACTIVE,UCOUNTRY,USTATE,UCITY,UZIP)
values('NULL','$fname','$mname','$lname','$uname','$sex','$password','$email','$bday',$bmonth','$byear','$ip','$activation','$country','$state','$city','$zip')")){
$message = " To activate your account, please click on this link:\n\n";
$message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation";
mail($email, 'Registration Confirmation', $message, 'From:'.EMAIL);
echo "<div style=\"position:relative; top:0; left:0; width:500; height:500; z-index:1;\">Thank you for
registering! A confirmation email has been sent to $Email <br>Please click on the Activation Link to Activate your account </div>";}
else{ echo "Database Problem, please contact Site admin";
//echo mysql_error();
}
}
?>
Here is the include file (includes DB connect information)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The BS Network</title>
</head>
<?php
/*Define constant to connect to database */
DEFINE('DATABASE_USER', 'poetgos7_axman');
DEFINE('DATABASE_PASSWORD', 'hollyone');
DEFINE('DATABASE_HOST', 'localhost');
DEFINE('DATABASE_NAME', 'poetgos7_bsnetwork');
/*Default time zone ,to be able to send mail */
date_default_timezone_set('UTC');
/*You might not need this */
ini_set('SMTP', "mail.myt.mu");
// Overide The Default Php.ini settings for sending mail
//This is the address that will appear coming from ( Sender )
define('EMAIL', 'donotreply@thebsnetwork.org');
/*Define the root url where the script will be found such as
http://website.com or http://website.com/Folder/ */
DEFINE('WEBSITE_URL', 'http://www.thebsnetwork.org');
// Make the connection:
$dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
DATABASE_NAME);
if (!$dbc) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
?>
<div id="container">
<div>
<img src="/images/layout.png">
The error I am getting is quite strange. The program is saying Warning: mysql_query() [function.mysql-query]: Access denied for user 'poetgos7'@'localhost' (using password: NO) in /home/poetgos7/thebsnetwork/signup.php on line 89
which makes no sense since I am not even attempting to access the database via the user poetgos7 0_o. Also, it appears that there is no error with my database connect script.
Any ideas? Thanks in advance.