Often, we use Ajax to implement a form that is not refreshed. Some time ago I followed the boss. Another way of not refreshing a submit form. Now put it out and share it with everyone.
First type:
(HTML page)
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> No refresh submission Form </title>
<style type= "Text/css" >
ul{List-style-type:none;}
</style>
<body>
<iframe name= "Formsubmit" style= "Display:none;" >
</iframe>
<!--point the window submitted by form to the hidden Ifrmae and submit the data through Ifrmae. -->
<form action= "form.php" method= "POST" name= "formphp" target= "Formsubmit" >
<ul>
<li>
<label for= "uname" > Username:</label>
<input type= "text" name= "uname" id= "uname"/>
</li>
<li>
<label for= "pwd" > Password:</label>
<input type= "password" name= "pwd" id= "pwd"/>
</li>
<li>
<input type= "Submit" value= "Login"/>
</li>
</ul>
</form>
</body>
(PHP page)
Copy Code code as follows:
<?php
Non-null validation
if (Empty ($_post[' uname ')) | | | empty ($_post[' pwd '])
{
Echo ' <script type= "Text/javascript" >alert ("NULL username or password!"); </script> ';
Exit
}
Verify Password
if ($_post[' uname ']!= ' Jack ' | | $_post[' pwd ']!= ' 123456 ')
{
Echo ' <script type= "Text/javascript" >alert ("Incorrect username or password!"); </script> ';
Exit
} else {
Echo ' <script type= "Text/javascript" >alert ("Login successful!"); </script> ';
Exit
}