This is my registration form page(Member_reg.php).
<html><head>
<script type="text/javascript">
function validateForm()
var a=document.forms["form1"]["username"].value;
var b=document.forms["form1"]["password"].value;
var c=document.forms["form1"]["mailid"].value;
var d=document.forms["form1"]["address"].value;
var e=document.forms["form1"]["contact"].value;
if (a==null || a=="")
{
alert("Username must be filled out");
return false;
}
else if (b==null || b=="")
{
alert("Password must be filled out");
return false;
}
else if (c==null || c=="")
{
alert("Email address must be filled out");
return false;
}
else if (d==null || d=="")
{
alert("Address must be filled out");
return false;
}
else if (e==null || e=="")
{
alert("Contact no must be filled out");
return false;
}
}
</script>
<--<style type="text/css">
table,td,th
{
border:1px solid black;
width:40%;
}
th
{
font-size:30pt;
background:#ccffcc;
color:green;
}
td
{
text-align:center;
font-weight:bold;
}
</style>-->
</head>
<body>
<form id="f1" name="form1" method="post" action="adduser.php" on Submit="return validateForm()">
<p align="center"><font size="+4">Registration Page</font>
<br>
<br>
<br>
<br>
<br>
<br>
<font size="+2">
</font>
<p><font size="+2">User name:
<input type="text" name="username" value="">
<br>
</font></p>
<font size="+2"><hr>
<br>
Password:
<input type="password" name="password" value="">
<br>
<hr>
<br>
Email ID:
<input type="text" name="mailid" value="">
<br>
<hr>
<br>
Address:
<input type="text" name="address" value="">
<br>
<hr>
<br>
Contact no:
<input type="text" name="contact" value="">
<br>
<hr>
<br>
Gender:
<input type="radio" name="radiobutton" value="myValue1">male<br>
<input type="radio" name="radiobutton" value="myValue2" checked>female
<br>
<hr>
<br>
Coutnry:
<select name="select"> <option value="Bangladesh">Bangladesh</option> <option value="India">India</option> <option value="Pakistan">Pakistan</option></select>
<br>
<hr>
<br>
Name of the institution:
<input type="institution" name="institution_name" value="">
<br>
<hr>
<br>
Type of the institution:
<select name="institution_type"> <option value="School">School</option> <option value="College">College</option> <option value="University">University</option></select>
<br>
<hr>
<br>
<input type="submit" value="submit">
</font>
<font size="+2">
<input name="reset" type="reset" value="reset">
</font>
</form>
</body>
</html>
And this my other php code(adduser.php).
<?php
include("Member_reg.php");
// get data that sent from registration form
$username=$_POST['username'];
$password=$_POST['password'];
$mailid=$_POST['mailid'];
$address=$_POST['address'];
$contact=$_POST['contact'];
$gender=$_POST['radiobutton'];
$country=$_POST['select'];
$institution=$_POST['institution'];
$type_institution=$_POST['institution_type'];
//$datetime=date("d/m/y h:i:s"); //create date time
$sql="INSERT INTO $tbl_name(username,password,mailid,address,contact,gender,country,institution,type_institution)VALUES('$username', '$password', '$mailid', '$address', '$contact','$gender','$country','$institution','$type_institution')";
$result=mysql_query($sql);
if($result){
echo "Successful<br>";
//echo "<a href=main_forum.php>View your topic</a>";
}
else {
echo "ERROR";
}
//mysql_close();
?>
When I submit anything the following messages are shown:/
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\php_prac\a\adduser.php on line 17
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\php_prac\a\adduser.php on line 17