this assignmet call for inserting data into the database and also retrieve. at one time it was inserting into the database but for strange reason it just stop inserting, i have search every noook and cranny within the code to find the error. I know that there is an error there that cause it to stop inserting. but what it is I really dont know. I am almost to the point of pulling out my hair. and another thing error is that I have set it to redirect it to the login page(this is the registration page am talking about) one mine it giving an error underfined index: gender in C, but I dont know how to fix it. ah lots of things is going on with this php codes and i cant seem to find what is worng and now am trying to validate it using js and cant get it to do it.
here is my html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Register </title>
<link rel="stylesheet" type="text/css" href="../css/stylesheet.css" />
</head>
<body>
<div id="container" >
<div id="header">
<img src="../images/header.jpg" alt="header" />
</div>
<div id="navbar">
<ul>
<li><a href="../index.html" id="tlinks" class="toplinks" >Homepage</a></li>
<li><a href="featureNationalWonders.html" id="thold" class="toplinks">Feature National Wonders</a></li>
<li><a href="contact.html" id="linkhold" class="toplinks">Contact Us</a></li>
<li><a href="register.html" id="phold" class="toplinks">Sign Up</a></li>
<li><a href="login_user.html" id="loglinks" class="toplinks">Login</a></li>
<li><a href="aboutus.html" id="panlinks" class="toplinks">About Us</a></li>
</ul>
<form method="post" id="search" action="" >
<div>
<input type="text" name="search" value=""/>
<input type="submit" value="Search"/>
</div>
</form>
</div>
<br/><br/>
<div id="contentArea">
<form method="post" action="../php/register_user1.php" name="frmRegister" onsubmit="return validateForm()";>
<p>
<label> User Personal Information</label>
</p>
<p>
<label>Title</label>
<select id="title" name="title">
<option value="" selected="selected" > Select a Title</option>
<option value="Ms">Ms.</option>
<option value="Mrs">Mrs.</option>
<option value="Mr">Mr.</option>
<option value="Dr">Dr.</option>
</select>
</p>
<p>
<label>First Name:</label>
<input type="text" name="firstname" id="firstname" size="47"/>
</p>
<p>
<label>Last Name:</label>
<input type="text" name="lastname" id="lastname" size="47"/>
</p>
<p>
<label> UserName:</label>
<input type="text" name="username" id="username" size="44"/>
</p>
<p>
<label> Email Address:</label>
<input type="text" id="email" name="email" size="43"/>
</p>
<p>
<label>Gender:</label>
<input type="radio" name="gender" id="m_male" value="male"/>Male
<input type="radio" name="gender" id="f_female" value="Female"/>Female
</p>
<p>
<label> Services:</label>
Magical Mermaid Hike: <input type="checkbox" name="services"/>
Kayaking:<input type="checkbox" name="services"/>
Turtle Watching:<input type="checkbox" name="services"/>
Bus Tours:<input type="checkbox" name="services"/>
Sightseeing:<input type="checkbox" name="services"/>
</p>
<p>
<label>Address:</label>
<textarea name="address" id="address" cols="46" rows="9"></textarea>
</p>
<p>
<label> Password: </label>
<input type="password" id="mypwd" name="mypwd" size="47"/>
</p>
<p>
<label>Confirm Password:</label>
<input type="password" name="confmypwd" id="confmywd" size="39"/>
</p>
<input type="submit" name="enter" value="Register" class="btnEnter"/>
<input type="reset" name="reset" value="RESET"/>
</form>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a>
</p>
<p>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
alt="Valid CSS!" />
</a>
</p>
</div>
<div id="footerFix"></div>
<div id="footerbox">
<div id="footer" >
<div id="footerholder">
<div>
<ul>
<li><a href="../index.html" class="toplinks" >Homepage</a></li>
<li><a href="featureNationalWonders.html" class="toplinks">Feature National Wonders</a></li>
<li><a href="contact.html" class="toplinks">Contact Us</a></li>
<li><a href="register_user.html" class="toplinks">Sign Up</a></li>
<li><a href="login_user.html" class="toplinks">Login</a></li>
<li><a href="aboutus.html" class="toplinks">About Us</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
and here is my php codes for it
<?php
$register=$_POST['register_user'];
if(isset($_POST['Register']))
{
//capture the variable from the form and store in php variables
$title=$_POST['title'];
$firstname=$_POST['firstname'];
<?php
$register=$_POST['register_user'];
if(isset($_POST['Register']))
{
//capture the variable from the form and store in php variables
$title=$_POST['title'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$email=$_POST['email'];
$gender= isset($_POST['gender']) && !empty($_POST['gender']);
$address=$_POST['address'];
$mypwd=$_POST['mypwd'];
include'db_server.php';
//Query the database
$sql="SELECT * FROM members WHERE username='$username'";
$result= mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());
$rowcount=mysqli_num_rows($result);
//checking to see if username is already exist
if($rowcount >= 1)
{
echo "<script type=\"text/javascript\">
alert('Welcome!! Firstname Lastname, you are now a member of the Caribbean Nature Seekers Institute TT(CNSITT)');
window.location=\"../login_user.html\";
</script>";
}
else
{
//insert data into table
$sql = "INSERT INTO members
VALUES('$title', '$firstname','$lastname', '$username', '$email', '$gender', '$address', md5('$mypwd'))";
if(mysqli_query($conn,$sql))
{
session_start();
$_SESSION['user']=$username;
header("location:login_user.html");
mysqli_close($conn);
}
else
{
echo "Error inserting values into database";
}
//end of line
}
}
?>
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$email=$_POST['email'];
$gender= isset($_POST['gender']) && !empty($_POST['gender']);
$address=$_POST['address'];
$mypwd=$_POST['mypwd'];
include'db_server.php';
//Query the database
$sql="SELECT * FROM members WHERE username='$username'";
$result= mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());
$rowcount=mysqli_num_rows($result);
//checking to see if username is already exist
if($rowcount >= 1)
{
echo "<script type=\"text/javascript\">
alert('Welcome!! Firstname Lastname, you are now a member of the Caribbean Nature Seekers Institute TT(CNSITT)');
window.location=\"../login_user.html\";
</script>";
}
else
{
//insert data into table
$sql = "INSERT INTO members
VALUES('$title', '$firstname','$lastname', '$username', '$email', '$gender', '$address', md5('$mypwd'))";
if(mysqli_query($conn,$sql))
{
session_start();
$_SESSION['user']=$username;
header("location:login_user.html");
mysqli_close($conn);
}
else
{
echo "Error inserting values into database";
}
//end of line
}
}
?>