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

What is the above code supposed to do?? And what do you mean by "A link to the server could not be established"??

Please make your question more clear.

You try to execute a mysql_query, but where do you connect to your database?

Try to enable the error reporting on your header of the script.

The first code is supposed to show a registration page where if any member gives his information and press submit,it will be updated to the database.
The second code is for creating a table in the database where the information of registration page will be updated.
How to remove those warnings?

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="Debate_Society"; // Database name
$tbl_name="userinfo"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect with the server");
mysql_select_db("$db_name")or die("cannot select Debate_Society");
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.