I designed a registration form for enabling new member to register and become a valid user. It seemed all working. while a new member fills out the form and click save buttom and shows successful reg. however, while displaying all members in database found no such member has been added. I think must be something wrong with SQL statment, but don't know what to do. I attached two main scripts would any one help me to check what the problem is please?
memberForm.php
<?php
function isValidMember ( $memberName , $emailAddress , $password,$searchName,
$sportName,$athleteName,$color,$countryName,$countryLanguage )
{
$result = true ;
if ( $memberName == "" )
{
$result = false;
print ( "A name must be entered<br>" ) ;
}
if ( $emailAddress == "" )
{
$result = false;
print ( "An vaild email address must be entered<br>" ) ;
}
if ( $password == "" )
{
$result = false;
print ( "you must enter your own password<br>" ) ;
}
if ( $searchName == "" )
{
$result = false;
print ( "you must select search name<br>" ) ;
}
if ( $sportName == "" )
{
$result = false;
print ( "you must select sport name<br>" ) ;
}
if ( $athleteName == "" )
{
$result = false;
print ( "you must select your favourite athlete<br>" ) ;
}
if ( $color == "" )
{
$result = false;
print ( "you must choose your favourite color<br>" ) ;
}
if ( $countryName == "" )
{
$result = false;
print ( "Please select your country name<br>" ) ;
}
if ( $countryLanguage == "" )
{
$result = false;
print ( "Please select your country main language<br>" ) ;
}
return $result ;
}
if ($_SERVER['REQUEST_METHOD'] == "POST" )
{
// grab the variables from the form
$memberName = $_POST["memberName"];
$emailAddress = $_POST["emailAddress"];
$password= $_POST["password"];
$searchName= $_POST["searchName"];
foreach ($_POST as $sName=>$value)
{
if ($value)$sportName[]=$sName;
}
$sportName= $_POST["sportName"];
$athleteName= $_POST["athleteName"];
$color= $_POST["color"];
$countryName= $_POST["countryName"];
$countryLanguage= $_POST["countryLanguage"];
// check all reqired areas have been entered
if (isValidMember ( $memberName , $emailAddress , $password,$searchName,
$sportName,$athleteName,$color,$countryName,$countryLanguage ) == true )
{
// specify where to save the session variables
session_save_path ( "./" ) ;
// start a new session
@session_start () ;
// add the variables to the $_SESSION associative array then load the next page
$_SESSION["memberName"] = $memberName;
$_SESSION["emailAddress"] = $emailAddress;
$_SESSION["password"] = $password;
$_SESSION["searchName"] = $searchName;
$_SESSION["sportName"] = $sportName;
$_SESSION["athleteName"] = $athleteName;
$_SESSION["color"] = $color ;
$_SESSION["countryName"] = $countryName;
$_SESSION["countryLanguage"] = $countryLanguage;
header ("Location:addMember.php") ;
}
else
{
print ( "So far, your registration is invalid" ) ;
}
}
?>
<html>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="memberForm.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><strong>Member Registration Form </strong></td>
</tr>
<tr>
<td width="20%">Your Name:</td>
<td width="80%"><input name="memberName" type="text" id="memberName"></td>
</tr>
<tr>
<td width="20%">Your email address:</td>
<td width="80%"><input name="emailAddress" type="text" id="emailAddress"></td>
</tr>
<tr>
<td width="20%">Your password:</td>
<td width="80%"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td width="20%">Please choose Your favourite search engine:</td>
<td width="80%"><input type="checkbox" name="searchName"> Google </input> 
<input type="checkbox" name="searchName"> Yahoo </input> 
<input type="checkbox" name="searchName"> AOL </input> 
<input type="checkbox" name="searchName"> MSN </input>
</td>
</tr>
<tr>
<td width="20%">Please select your favourite sport from the list</td>
<td width=80%"">
<select multiple name="sportName" size="2" >
<option value="1"> Athletics </option>
<option value="2"> Bowls </option>
<option value="3"> Basketball </option>
<option value="4"> Cycling </option>
<option value="5"> Netball </option>
<option value="6"> Football </option>
<option value="7"> Gymnastics </option>
<option value="8"> Swimming </option>
</select>
</td>
</tr>
<tr>
<td width="20%">Please choose Your favourite athletes:</td>
<td width="80%"><input type="radio" name="athleteName"> David Beckham </input> 
<input type="radio" name="athleteName"> Jane Williams </input> 
<input type="radio" name="athleteName"> Michale Schumack </input> 
<input type="radio" name="athleteName"> Michale Jordan</input>
</td>
</tr>
<tr>
<td width="20%">Please choose Your favourite color:</td>
<td width="80%"><input type="radio" name="color"> Blue </input> 
<input type="radio" name="color"> Yellow </input> 
<input type="radio" name="color"> Green </input> 
<input type="radio" name="color"> Red</input>
</td>
</tr>
<tr>
<td width="20%">Your country name:</td>
<td width="80%"><select name="countryName" size="2" >
<option value="1"> Australia </option>
<option value="2"> China </option>
<option value="3"> NewZealand </option>
<option value="4"> UK </option>
</select>
</td>
</tr>
<tr>
<td width="20%">Your country language:</td>
<td width="80%"><select name="countryLanguage" size="2" >
<option value="1"> English </option>
<option value="2"> Chinese </option>
</select></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Save Registration"></td>
<td><input type="reset" name="reset" value="Cancel"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</body>
</html>
addMember.php
<?php
session_save_path("./") ;
@session_start () ;
$memberName =$_SESSION["memberName"] ;
$emailAddress =$_SESSION["emailAddress"];
$password =$_SESSION["password"] ;
$searchName =$_SESSION["searchName"] ;
$sportName =$_SESSION["sportName"] ;
$athleteName = $_SESSION["athleteName"];
$color =$_SESSION["color"] ;
$countryName =$_SESSION["countryName"] ;
$countryLanguage =$_SESSION["countryLanguage"] ;
// Suppress errors and handle them internally
$aDBLink = @mysql_connect("localhost" , "root" ) ;
if ( !empty( $aDBLink) )
{
// print ("it connected to the server<br>") ;
if ( mysql_select_db( "cgames", $aDBLink ) == True )
{
// print ("it selected the database<br>" ) ;
// if memberID not already exists then adding else editing
$aSQL = "insert into member values(null,'$memberName','$engineID','$athleteID'
,'$color','$countryID','$emailAddress','$password')" ;
}
// execute the sql query
$aQResult = mysql_query($aSQL, $aDBLink ) ;
if ( $aQResult == true )
{
print ("<b>Your registration was successful, thank you!</b><br><br><br>") ;
}
else
{
print ("the sql was wrong!");
}
}
@session_destroy() ;
?>
<html>
<a href="main.php">Now you may click here to relogin </a>
Also, there are six tables in the data base which will be used for registration form:member,search, country,sport,athlete and memberSport(it resolves many to many relationship between member and sport tables)
Many thanks !