flex php 交互
原文地址:http://blog.sina.com.cn/s/blog_4dd475390100ryp9.html
创建数据库tiask 并执行下列sql
/*Navicat MySQL Data TransferSource Server : localhostSource Server Version : 50067Source Host : localhost:3306Source Database : tiaskTarget Server Type : MYSQLTarget Server Version : 50067File Encoding : 65001Date: 2011-10-09 16:59:33*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for `flextest`-- ----------------------------DROP TABLE IF EXISTS `flextest`;CREATE TABLE `flextest` ( `name` varchar(10) NOT NULL, `pwd` longtext, PRIMARY KEY (`name`)) ENGINE=MyISAM DEFAULT CHARSET=gb2312;-- ------------------------------ Records of flextest-- ----------------------------INSERT INTO `flextest` VALUES ('user', '1234');-- ------------------------------ Table structure for `user_list`-- ----------------------------DROP TABLE IF EXISTS `user_list`;CREATE TABLE `user_list` ( `name` longtext, `pwd` longtext) ENGINE=MyISAM DEFAULT CHARSET=gb2312;-- ------------------------------ Records of user_list-- ----------------------------INSERT INTO `user_list` VALUES ('user', '1234');
flex部分:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; import mx.controls.Alert; [Bindable] private var result1:ArrayCollection; private var login_result:String; [Bindable] private var sendChoice:String; private function goLogin():void{ if(username.text=="" || userpwd.text=="") Alert.show("没有填写用户名或密码"); else{ sendChoice="login"; login.send(); } } private function goRegis():void{ if(username.text=="" || userpwd.text=="") Alert.show("没有填写用户名或密码"); else{ sendChoice="regis"; login.send(); } } private function resultHandler(event:ResultEvent):void{ login_result=event.result.html.body.users.a.toString(); if(login_result=="ok"){ Alert.show("欢迎,登录成功"); } if(login_result=="nohave"){ Alert.show("没有找到这个用户名 请先注册!"); } if(login_result=="pwderror"){ Alert.show("密码错误! 请从新登陆!"); } if(login_result=="nameishave"){ Alert.show("用户名已经存在,请选择别的用户名注册"); } if(login_result=="regisok"){ Alert.show("注册成功,请从新登陆"); } if(login_result=="error"){ Alert.show("错误"); } } ]]> </mx:Script> <mx:HTTPService id="login" method="POST" showBusyCursor="true" url="http://localhost/testflex.php" result="resultHandler(event)"> <mx:request xmlns=""> <mx:username> {username.text} </mx:username> <mx:userpwd> {userpwd.text} </mx:userpwd> <mx:sendchoice> {sendChoice} </mx:sendchoice> </mx:request> </mx:HTTPService> <mx:Panel width="310" height="265" layout="absolute" title="登录" fontSize="12" fontWeight="normal"> <mx:TextInput x="93" y="51" id="username" fontSize="12" restrict="0-9,a-z" maxChars="8"/> <mx:TextInput x="92" y="95" id="userpwd" fontSize="12" displayAsPassword="true" maxChars="8" restrict="0-9,a-z"/> <mx:Button x="78" y="154" label="登录" id="btn1" click="goLogin()" fontWeight="normal" fontSize="12"/> <mx:Label x="32" y="53" text="用户名:" fontSize="12"/> <mx:Label x="43" y="97" text="密码:" fontSize="12"/> <mx:Button x="154" y="154" label="注册" fontSize="12" fontWeight="normal" id="btn2" click="goRegis()"/> <mx:Label x="10" y="10" text="测试用 用户名 user 密码 1234" fontSize="12" width="243"/> </mx:Panel> </mx:Application>
php部分:e
testflex.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>flex login</title> </head> <body> <?php $return=""; if(isset($_POST[username]) && isset($_POST[userpwd]) && isset($_POST[sendchoice])){ $uname=$_POST[username]; $upwd=$_POST[userpwd]; $choice=$_POST[sendchoice]; $link = mysql_connect("localhost","root","") or die (mysql_error()); if($link){ $select=mysql_select_db("tiask",$link); mysql_query("set names gb2312"); if($choice=="login"){ $sql=mysql_query("select * from flextest where name='$uname'"); $result=mysql_fetch_object($sql); if($result==false){ $return='<users>'; $return.='<a>nohave</a>'; $return.='</users>'; }else if($result->pwd==$upwd){ $return='<users>'; $return.='<a>ok</a>'; $return.='</users>'; }else{ $return='<users>'; $return.='<a>pwderror</a>'; $return.='</users>'; } } if($choice=="regis"){ $sql=mysql_query("select * from user_list where name='$uname'"); $result=mysql_fetch_object($sql); if($result==false){ $sql_1=mysql_query("insert into user_list(name,pwd) values('$uname','$upwd')",$link); if($sql_1){ $return='<users>'; $return.='<a>regisok</a>'; $return.='</users>'; } }else{ $return='<users>'; $return.='<a>nameishave</a>'; $return.='</users>'; } } } mysql_close(); } else{ $return='<users>'; $return.='<a>error</a>'; $return.='</users>'; } echo $return;?> </body> </html>
完

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
