<?php
include('connection.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function chk(form)
{
if(form.txtname.value=="")
{
form.txtname.focus();
document.getElementById("a11").innerHTML="Blank not allow";
return false;
}
var ar = document.getElementById("a1").value;
if(ar=="true")
{
}
else {
return false;
}
return true;
}
function userchk(str)
{
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("msg").innerHTML = xmlhttp.responseText;
if(xmlhttp.responseText=="user name not valid")
{
document.getElementById("a1").value="false";
}
else {
document.getElementById("a1").value="true";
}
}
}
xmlhttp.open("GET","ajax1.php?id="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form name="f1" method="post" onsubmit="return chk(this);">
<input type="text" name="txtname" onBlur="userchk(this.value)" />
<span id="msg"></span>
<span id="a11"></span>
<input type="hidden" name="a1" value="" id="a1" />
<input type="submit" name="btnadd" />
</form>
<?php
if(isset($_POST['btnadd']))
{
$txtname=$_POST['txtname'];
$sql="insert into simple(uname) values('$txtname')";
$sqlexc=mysqli_query($dd,$sql);
if(!$sqlexc)
{
echo mysql_error();
}
else {
echo "<script>alert(' insert data');</script>";
}
}
?>
</body>
</html>
include('connection.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function chk(form)
{
if(form.txtname.value=="")
{
form.txtname.focus();
document.getElementById("a11").innerHTML="Blank not allow";
return false;
}
var ar = document.getElementById("a1").value;
if(ar=="true")
{
}
else {
return false;
}
return true;
}
function userchk(str)
{
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("msg").innerHTML = xmlhttp.responseText;
if(xmlhttp.responseText=="user name not valid")
{
document.getElementById("a1").value="false";
}
else {
document.getElementById("a1").value="true";
}
}
}
xmlhttp.open("GET","ajax1.php?id="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form name="f1" method="post" onsubmit="return chk(this);">
<input type="text" name="txtname" onBlur="userchk(this.value)" />
<span id="msg"></span>
<span id="a11"></span>
<input type="hidden" name="a1" value="" id="a1" />
<input type="submit" name="btnadd" />
</form>
<?php
if(isset($_POST['btnadd']))
{
$txtname=$_POST['txtname'];
$sql="insert into simple(uname) values('$txtname')";
$sqlexc=mysqli_query($dd,$sql);
if(!$sqlexc)
{
echo mysql_error();
}
else {
echo "<script>alert(' insert data');</script>";
}
}
?>
</body>
</html>
No comments:
Post a Comment