No need to submit a new HTML form, html submit a form

Source: Internet
Author: User

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;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.