Undefined index: email in C:\wamp\www\emailvalidate.php on line 4
- by klari
I am new to Ajax. In my Ajax I get the following error message :
Notice: Undefined index: address in C:\wamp\www\test\sample.php on
line 11
I googled but I didn't get a solution for my specified issue.
Here is what I did.
HTML Form with Ajax (test1.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>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mydiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","test2.php",true);
xmlhttp.send();
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="sample.php">
<p>
<label for="mail"></label>
<input type="text" name="mail" id="mail" onblur="loadXMLDoc()" />
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
<p><div id = 'mydiv'></div></p>
</form>
</body>
</html>
test2.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>
</head>
<body>
<?php
echo "Your Address is ".$_POST['address'];
?>
</body>
</html>
I am sure it is very simple issue but I don't know how to solve it. Any help ?