I'm trying send some AJAX(not Jquery AJAX) parameter to a server with HTML form values and store it a database. But it doesn't work correctly. When i hit the Let's start button i have got my error message Here is my code....
<div class ="col-xs-12 col-md-12 col-sm-12 col-lg-12" id ="AJAXsignup">
<h3>Creating a new account...</h3>
<input class ="form-control" type ="text" name ="fullname" placeholder ="Type your name eg:-Jhon Smith" id ="namefull">
<span class ="label label-warning" id ="err_fullname">You should type your name</span>
<input class ="form-control" type ="text" name ="username" placeholder ="Type your user name eg:-Jhon 95" id ="nameuser" style ="margin-top:5px;">
<span class ="label label-warning" id ="err_username">Missing username</span>
<div class ="input-group">
<span class ="input-group-addon">@</span>
<input class ="form-control" type ="email" name ="email" placeholder ="Type your Email" id ="email" style ="margin-top:5px;">
<span class ="label label-warning" id ="err_email">Missing email</span>
</div>
<input class ="form-control" type ="password" name ="password" placeholder ="Type your Password" id ="pass" style ="margin-top:5px;">
<span class ="label label-warning" id ="err_password">Missing Password</span>
<input class ="form-control" type ="password" name ="password" placeholder ="Repeat your Password" id ="repass" style ="margin-top:5px;">
<span style ="margin-bottom:5px;" class ="label label-warning" id ="err_repass">Repeat Password</span>
<img class ="col-sm-offset-5 col-md-offset-5 col-lg-offset-5" src ="images\Preloader_2.gif" id ="loader" style ="display:none;" style ="margin-bottom:5px;">
<input class ="btn btn-lg btn-info col-md-12 col-lg-12 col-sm-12 col-xs-12" type ="submit" id ="btn" value ="Let's start!" style ="margin-bottom:5px;" onclick = "validate()">
<input class ="btn btn-lg btn-danger col-md-12 col-lg-12 col-sm-12 col-xs-12"type ="button" id ="frm-can" value ="No.Thanks">
</div>
The JAVASCRIPT code
function sendinginfomation(){
if(window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
xmlhttp = new XMLHttpRequest();
}
var fullname = document.getElementById('namefull').value;
var user_n = document.getElementById('nameuser').value;
var email = document.getElementById('email').value;
var user_p = document.getElementById('pass').value;
xmlhttp.open("GET",'php/signup.php?w='+fullname+"&n_p="+user_n+"&tv="+email+"&q="+user_p,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState ==4){
$("#loader").fadeOut(300);
document.getElementById('AJAXsignup').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
The PHP code
$fullname = $_GET['w'];
$username = $_GET['n_p'];
$email = $_GET['tv'];
$password = $_GET['q'];
$server = "localhost";
$username = "root";
try{
$conn = new PDO("mysql:host=$server;dbname=reg_mem",$username);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO mem_info(Full_name,User_name,Email,Password) VALUES($fullname,$username,$email,$password)";
$conn->exec($sql);
echo "The infomation sent sunncessfully.";
}catch(PDOException $e){
echo "The infomation unable to send right now";
}