When i enter the data to the form, Which is
FORM
HTML Code:
<form action="registration-process.php" method="post">
<div align="left"><br />
</div>
<hr align="left" />
<div align="right"><strong>First Name :</strong>
<input name="firstname" type="text" />
<br />
<strong>Last Name :</strong>
<input name="lastname" type="text" />
<strong><br />
Email Address :</strong>
<input name="email" type="text" />
<strong><br />
Confirm Email Address : </strong>
<input name="emailc" type="text" />
</div>
<HR align="left" />
<div align="right"><strong>Username :</strong>
<input name="user" type="text" />
<br />
<strong>Password : </strong>
<input name="password" type="password" />
<strong><br />
Confirm Password :</strong>
<input name="passwordc" type="password" />
</div>
<hr align="left" />
<div align="right"><span class="style3">First 4 Letters or Numbers of </span><strong>Post Code : </strong>
<input name="post" type="text" />
<strong><br />
Phone Area Code :</strong>
<input name="phone" type="text" />
<strong><br />
First two letters of name :</strong>
<input name="twoletter" type="text" />
<br />
<input name="Register" type="submit" value="Register" />
</div>
</form>
And then is goes to the process page, and it just comes up Query failed
and the only place i got that is on line 97
Which the code before then is
PHP Code:
<?php
//Start session
session_start();
//Include database connection details
require_once('config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$firstname = clean($_POST['firstname']);
$lastname = clean($_POST['lastname']);
$user = clean($_POST['user']);
$password = clean($_POST['password']);
$passwordc = clean($_POST['passwordc']);
$email = clean($_POST['email']);
$emailc = clean($_POST['emailc']);
$post = clean($_POST['post']);
$twoletter = clean($_POST['twoletter']);
$phone = clean($_POST['phone']);
//Input Validations
if($firstname == '') {
$errmsg_arr[] = 'First name missing';
$errflag = true;
}
if($lastname == '') {
$errmsg_arr[] = 'Last name missing';
$errflag = true;
}
if($user == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($passwordc == '') {
$errmsg_arr[] = 'Confirm password missing';
$errflag = true;
}
if( strcmp($password, $passwordc) != 0 ) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}
if($email == '') {
$errmsg_arr[] = 'email Missing';
$errflag = true;
}
if($emailc == '') {
$errmsg_arr[] = 'Confirm email missing';
$errflag = true;
}
if( strcmp($email, $emailc) != 0 ) {
$errmsg_arr[] = 'email do not match';
$errflag = true;
}
//Check for duplicate login ID
if($user != '') {
$qry = "SELECT * FROM members WHERE username = '$user'";
$result = mysql_query($qry);
if($result) {
if(mysql_num_rows($result) > 0) {
$errmsg_arr[] = 'Username ID already in use';
$errflag = true;
}
@mysql_free_result($result);
}
else {
die("Query failed");
}
}
There is no error message