<html>
<script type="text/javascript">
function user()
{
var name = document.getElementById("name");
var address = document.getElementById("address");
var email = document.getElementById("email");
var password = document.getElementById("password");
var reenterpassword = document.getElementById("reenterpassword");
if(isAlphabet(name,"please enter the name")){
if(isAlphabet1(address,"please enter the address")){
if(isAlphabet2(email,"please enter the email")){
if(isAlphabet3(password,"please enter the password")){
if(isAlphabet4(repassword,"please enter the password")){
return true;
}
}
}
}
}
else{
return false;
}
}
function notEmpty(elem,helMsg){
if(elem.vlaue.length==0){
alert("helMsg");
elem.fouse();
return false;
}
return true;
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet1(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}function isAlphabet2(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}function isAlphabet3(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
</script>
</html>
<center>
<form method="POST" onsubmit="return user()">
<b>Registration form</b>
<table border='5' bgcolor='yellow'>
<tr>
<td>Name</td>
<td><input type ='text' name='name' id='name'></td></tr>
<tr>
<td>address</td><td><input type ='text' name="address" id='address'></td></tr>
<tr>
<td>emailid</td><td><input type='text' name="email" id='emailid'></td></tr>
<tr>
<td>username</td><td><input type='text' name="username" id='username'></td></tr>
<tr>
<td>password</td><td><input type='password' name="password" id='password'></td></tr>
<td><input type='reset'></td>
<td><input type="submit" name="submit"value="submit"></td></tr>
</table>
</form>
</center>
</html>
<?php
if(isset($_POST['submit'])){
$conn=mysql_connect("localhost","root","");
mysql_select_db("user",$conn) or die('could not connect:' . mysql_error());
$name = $_POST["name"];
$address = $_POST["address"];
$email = $_POST["email"];
$username =$_POST["username"];
$password =$_POST["password"];
$query = "INSERT INTO tab(id,name,email,username,password) VALUES('','".$name."','".$email."','".$username."','".$password."')";
//echo "$query";
mysql_query("$query");
}
else
{
echo "Records are Not Inserted";
}
?>
No comments:
Post a Comment