PHP Simple Demo Login Function instance sharing

Source: Internet
Author: User
Regardless of the verification Code, PHP implementation of the simulation login, the method is generally used to simulate the implementation of curl, but curl is the server-side and server-side set up a session, can only simulate the landing after the landing data, The cookie information cannot be planted on the client (at least for the moment I find no way to find it) and finally by the hidden IFrame. This article mainly introduces the PHP simple implementation of the simulation landing function, involving PHP using curl to achieve the simulation landing of the relevant operation skills, the need for friends can refer to, hope to help everyone.

1, curl implementation of the code to simulate the login (just to implement the server and the server to establish a session, in fact, there is no session between the client and the server)


<?php$cookie_jar = Tempnam ('./tmp ', ' Cookie '); $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, ' http://192.168.0.22/logincheck.php '); curl_setopt ($ch, Curlopt_post, 1); $request = ' uname=admin &password=123456 '; curl_setopt ($ch, Curlopt_postfields, $request);//Save the returned cookie information in the $cookie_jar file curl_setopt ($ch, Curlopt_cookiejar, $cookie _jar);//Set whether the returned data is automatically displayed curl_setopt ($ch, Curlopt_returntransfer, 1);//Set whether to display header information Curl_ Setopt ($ch, Curlopt_header, false);//sets whether to output page content curl_setopt ($ch, Curlopt_nobody, false); curl_exec ($ch); Curl_close ($ CH);//get data after login$ch2 = Curl_init () curl_setopt ($ch 2, Curlopt_url, ' http://192.168.0.22/general/'); curl_ Setopt ($ch 2, Curlopt_header, false); curl_setopt ($ch 2, Curlopt_returntransfer, 1); curl_setopt ($ch 2, Curlopt_ Cookiefile, $cookie _jar); $orders = Curl_exec ($ch 2); echo $orders; Exit;echo ' <pre> '; Echo strip_tags ($orders); Echo ' </pre> '; Curl_close ($ch 2);? 

2, through the hidden IFRAME to achieve client-server communication (Ken can bring a certain security risks)



ceshi1.php

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.