No need to submit a new HTML form, html submit a form
We usually use ajax to implement the process of refreshing new forms. Some time ago, I learned from the boss that another method of refreshing new forms is implemented using the iframe framework. Now let's sort it out and share it with you.
First:
(Html page)
<! Doctype html> <! -- Points the form submission window to a hidden ifrmae and submits data through ifrmae. --> <Form action = "form. php "method =" POST "name =" formphp "target =" formsubmit "> <ul> <li> <label for =" uname "> User name: </label> <input type = "text" name = "uname" id = "uname"/> </li> <label for = "pwd"> Password: </label> <input type = "password" name = "pwd" id = "pwd"/> </li> <input type = "submit" value =" log on to "/> </li> </ul> </form> </body>
(PHP page: form. php)
<? Php // if (empty ($ _ POST ['uname']) | empty ($ _ POST ['pwd']) {echo '<script type = "text/javascript"> alert ("the user name or password is blank! "); </Script> '; exit;} // verify the password if ($ _ POST ['uname']! = 'Jack' | $ _ POST ['pwd']! = '000000') {echo '<script type = "text/javascript"> alert ("incorrect user name or password! "); </Script> '; exit;} else {echo' <script type =" text/javascript "> alert (" Logon successful! "); </Script> '; exit ;}
Second:
(Html page)
<! Doctype html>
(PHP page: form. php)
<? Php // set the time zone date_default_timezone_set ('prc');/* returned submission message status: status msg: prompt message */$ msg = array ('status' => 0, 'msg '=> ''); // obtain the submitted data $ name = $ _ POST ['username']; $ pwd =$ _ POST ['userpwd']; // simulate logon verification $ user = array (); $ user ['name'] = 'jack'; $ user ['pwd'] = 'jack2014 '; if ($ name! = $ User ['name']) {$ msg ['msg '] =' This user is not registered! '; $ Str = json_encode ($ msg); echo $ str; exit;} else if ($ pwd! = $ User ['pwd']) {$ msg ['msg '] = 'incorrect password! '; $ Str = json_encode ($ msg); echo $ str; exit;} $ msg ['msg'] = 'login successful! '; $ Msg ['status'] = 1; $ str = json_encode ($ msg); echo $ str;