<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> Login Angularjs</title>
<meta charset= "UTF-8" >
<meta name= "viewport" content= "Width=device-width, Initial-scale=1,maximum-scale=1,user-scalable=no" >
<link rel= "stylesheet" href= "Css/bootstrap.min.css" >
<link rel= "stylesheet" href= "Css/login.css"/>
<script type= "Text/javascript" src= "Js/jquery-1.8.1.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {//dom
$ ("#button"). Click (function () {///When the button is clicked the handler function
PostData (); Execute PostData function when button is clicked
});
});
function PostData () {//Submit data functions
$.ajax ({//Invoke jquery's Ajax method
Type: "POST",//Set the form of Ajax method submission data
URL: "ajax_output.php",//Submit data to ok.php
Data: "Username=" +$ ("#username"). Val () + "&pass= "+$" ("#pass"). Val () + "&age= "+$" ("#age"). Val (),//input box Username pass age multiple values& SymbolsThe value in the file as the submitted data
Success:function (msg) {//Post successful callback, MSG variable is the content of the ok.php output.
Alert ("Data submitted successfully"); If necessary, you can display the value of the MSG variable in a DIV element
}
});
}
</script>
<body>
<div class= "Container" >
<div class= "img-responsive" id= "MSG" ></div>
<form class= "Form-signin" id= "Form1" method= "Post" name= "User_info" action= "" >
<input name= "username" id= "username" type= "text" value= ""/>
<input name= "Pass" id= "pass" type= "text" value= ""/>
<input name= "Age" id= "age" type= "text" value= ""/>
<input type= "Submit" name= "button" id= "button" value= "Submit"/>
</form>
</div>
</body>
<?php
header ("Content-type:text/html;charset=utf-8");
/* $mysql _username= "localhost"; Connect database user name
$mysql _password= "";//Connect Database Password */
$mysql _database= "test"; Database name
//Connect to database
$conn = mysql_connect (' localhost ', ' Root ', ') or Die ("Mysql_connect:". Mysql_errno ());
mysql_select_db ($mysql _database);
$username =$_post[' username '];
$pass =$_post[' pass ');
$age =$_post[' age '];
$sql = "INSERT into ' login2 ' VALUES (' $username ', ' $pass ', ' $age ')";
$query = mysql_query ($sql);
if ($query) {
echo ' 1 ';
}else{
echo ' registration failed! ';
}
;
Ajax form submission No refresh