我正在尝试为网站生成contact.php,但它没有填写字段。 现在我有这个:
<?php
$to = "myemail@gmail.com";
$name = $_POST['nametxt'] ;
$message = $_POST['messagetxt'] ;
$subject = $_POST['subjecttxt'] ;
$from = $_POST['emailtxt'] ;
mail($to,$name,$message,$from,$subject);
echo "Mail Sent.";
?>
但我收到一封空电子邮件。 最初的.fla是Here。
这是来自form_4.as
package contact_fla
{
import flash.display.*;
import flash.text.*;
dynamic public class form_4 extends MovieClip
{
public var messagetxt:TextField;
public var send_btn:MovieClip;
public var nametxt:TextField;
public var emailtxt:TextField;
public var errortxt:TextField;
public var reset_btn:MovieClip;
public var subjecttxt:TextField;
public function form_4()
{
return;
}// end function
}
}
这是来自Contactview.as
package pages.views
{
import com.gaiaframework.templates.*;
import com.shuhanarts.as3.*;
import com.shuhanarts.as3.ui.forms.*;
import com.shuhanarts.as3.utils.*;
import flash.display.*;
import flash.text.*;
import pages.utils.*;
import pages.views.components.*;
public class ContactView extends AbstractView
{
protected var xml:XML;
private var onOutColor:Number = 16777215;
private var onOverColor:Number = 16776960;
public function ContactView(param1:MovieClip, param2:Object, param3:AbstractPage = null)
{
onOverColor = 16776960;
onOutColor = 16777215;
super(param1, param2, param3);
onOverColor = Number(ConfigUtils.parseNavigate().setting.onOverColor);
onOutColor = Number(ConfigUtils.parseNavigate().setting.onOutColor);
TweenerButton.init();
ColorUtil.setRGB(param1.form.form.reset_btn.icon, onOutColor);
TweenerButton.run(param1.form.form.reset_btn.icon, "color", onOutColor, onOverColor);
ColorUtil.setRGB(param1.form.form.send_btn.icon, onOutColor);
TweenerButton.run(param1.form.form.send_btn.icon, "color", onOutColor, onOverColor);
return;
}// end function
public function onLoadSourceInit(param1:XML) : void
{
this.xml = param1;
_initUI();
ON_LOAD_XML_COMPLETE.dispatch();
return;
}// end function
protected function parseForm() : Object
{
var _loc_1:Object = null;
var _loc_2:Object = null;
var _loc_3:Object = null;
_loc_1 = {};
_loc_2 = {};
_loc_3 = {};
_loc_2.name = xml.form.name.@text;
_loc_2.email = xml.form.email.@text;
_loc_2.message = xml.form.message.@text;
_loc_2.subject = xml.form.subject.@text;
_loc_3.normalBorder = Number(xml.form.border.@normal);
_loc_3.selectBorder = Number(xml.form.border.@focus);
_loc_3.normalBackground = Number(xml.form.background.@normal);
_loc_3.selectBackground = Number(xml.form.background.@focus);
_loc_3.normalColor = Number(xml.form.text.@normal);
_loc_3.selectColor = Number(xml.form.text.@focus);
_loc_1.textObj = _loc_2;
_loc_1.colorObj = _loc_3;
_loc_1.active = xml.form.@active == "true" ? (true) : (false);
return _loc_1;
}// end function
override public function initUI() : void
{
load();
return;
}// end function
protected function _initUI() : void
{
var _loc_1:TextField = null;
_loc_1 = container.txt;
_loc_1.htmlText = xml.text.text();
_loc_1.mouseWheelEnabled = false;
_initPHPForm();
return;
}// end function
public function load() : void
{
var _loc_1:String = null;
var _loc_2:XMLLoader = null;
_loc_1 = data.source;
_loc_2 = new XMLLoader();
_loc_2.ONLOADINIT_EVENT.add(onLoadSourceInit);
_loc_2.load(_loc_1);
return;
}// end function
protected function _initPHPForm() : void
{
var _loc_1:MovieClip = null;
var _loc_2:Object = null;
var _loc_3:PHPContactForm = null;
_loc_1 = container.form;
_loc_2 = parseForm();
_loc_3 = new PHPContactForm(_loc_1, "contact.php", !_loc_2.active, _loc_2.textObj, _loc_2.colorObj);
return;
}// end function
}
}
可能来自这里:
package com.shuhanarts.as3.ui.forms
{
import com.shuhanarts.as3.*;
import com.shuhanarts.as3.ui.*;
import com.shuhanarts.as3.utils.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class PHPContactForm extends Component
{
private var _send_btn:Object;
private var _file_url:String;
private var _name_txt:SmartInputText;
private var _subject_txt:SmartInputText;
private var _target:MovieClip;
private var _form_mc:MovieClip;
private var _error_txt:TextField;
private var _isPreview:Boolean;
private var _messBox_mc:MovieClip;
private var _textObj:Object;
private var _email_txt:SmartInputText;
private var _reset_btn:Object;
private var _colorObj:Object;
private var _mesBoxClode_btn:Object;
private var _message_txt:SmartInputText;
public function PHPContactForm(param1:MovieClip, param2:String = "http://localhost/contact.php", param3:Boolean = false, param4:Object = null, param5:Object = null)
{
this._target = param1;
_form_mc = this._target.form;
_messBox_mc = this._target.mesbox;
_file_url = param2;
_isPreview = param3;
_textObj = param4;
_colorObj = param5;
init();
return;
}// end function
private function setTextView() : void
{
if (!_textObj)
{
_email_txt = new SmartInputText(_form_mc.emailtxt, "Your Email");
_name_txt = new SmartInputText(_form_mc.nametxt, "Your Name");
_message_txt = new SmartInputText(_form_mc.messagetxt, "Your Message");
_subject_txt = new SmartInputText(_form_mc.subjecttxt, "Your Subject");
}
else
{
_email_txt = new SmartInputText(_form_mc.emailtxt, _textObj.email);
_name_txt = new SmartInputText(_form_mc.nametxt, _textObj.name);
_message_txt = new SmartInputText(_form_mc.messagetxt, _textObj.message);
_subject_txt = new SmartInputText(_form_mc.subjecttxt, _textObj.subject);
}
return;
}// end function
private function init() : void
{
setTextView();
setColorView();
_reset_btn = _form_mc.reset_btn;
_send_btn = _form_mc.send_btn;
_mesBoxClode_btn = _messBox_mc.close_btn;
_error_txt = _form_mc.errortxt;
_reset_btn.addEventListener(MouseEvent.CLICK, reset);
_send_btn.addEventListener(MouseEvent.CLICK, send);
_mesBoxClode_btn.addEventListener(MouseEvent.CLICK, clodeMessageBox);
return;
}// end function
private function setColorView() : void
{
if (!_colorObj)
{
}
else
{
_name_txt.normalBorder = _colorObj.normalBorder;
_name_txt.selectBorder = _colorObj.selectBorder;
_name_txt.normalBackground = _colorObj.normalBackground;
_name_txt.selectBackground = _colorObj.selectBackground;
_name_txt.normalColor = _colorObj.normalColor;
_name_txt.selectColor = _colorObj.selectColor;
_name_txt.getTarget().textColor = _colorObj.normalColor;
_email_txt.normalBorder = _colorObj.normalBorder;
_email_txt.selectBorder = _colorObj.selectBorder;
_email_txt.normalBackground = _colorObj.normalBackground;
_email_txt.selectBackground = _colorObj.selectBackground;
_email_txt.normalColor = _colorObj.normalColor;
_email_txt.selectColor = _colorObj.selectColor;
_email_txt.getTarget().textColor = _colorObj.normalColor;
_subject_txt.normalBorder = _colorObj.normalBorder;
_subject_txt.selectBorder = _colorObj.selectBorder;
_subject_txt.normalBackground = _colorObj.normalBackground;
_subject_txt.selectBackground = _colorObj.selectBackground;
_subject_txt.normalColor = _colorObj.normalColor;
_subject_txt.selectColor = _colorObj.selectColor;
_subject_txt.getTarget().textColor = _colorObj.normalColor;
_message_txt.normalBorder = _colorObj.normalBorder;
_message_txt.selectBorder = _colorObj.selectBorder;
_message_txt.normalBackground = _colorObj.normalBackground;
_message_txt.selectBackground = _colorObj.selectBackground;
_message_txt.normalColor = _colorObj.normalColor;
_message_txt.selectColor = _colorObj.selectColor;
_message_txt.getTarget().textColor = _colorObj.normalColor;
_name_txt.update();
_email_txt.update();
_message_txt.update();
_subject_txt.update();
}
return;
}// end function
private function send(event:MouseEvent = null) : void
{
var _loc_2:Boolean = false;
var _loc_3:Boolean = false;
var _loc_4:Boolean = false;
var _loc_5:Boolean = false;
_loc_2 = _name_txt.getText() != "" && _name_txt.isDefaultString();
_loc_3 = _message_txt.getText() != "" && _message_txt.isDefaultString();
_loc_4 = _subject_txt.getText() != "" && _subject_txt.isDefaultString();
_loc_5 = StringUtil.isValidEmail(_email_txt.getText());
if (_loc_2 == true)
{
_error_txt.text = "** Username Required **";
_target.stage.focus = _name_txt.getTarget();
return;
}
if (_loc_5 == false)
{
_error_txt.text = "** Missing field/Invalid email **";
_target.stage.focus = _email_txt.getTarget();
return;
}
if (_loc_4 == true)
{
_error_txt.text = "** Subject Required **";
_target.stage.focus = _subject_txt.getTarget();
return;
}
if (_loc_3 == true)
{
_error_txt.text = "** Message Required **";
_target.stage.focus = _message_txt.getTarget();
return;
}
$send();
return;
}// end function
private function showMessageBox(param1:Number = 0) : void
{
_form_mc.mouseEnabled = false;
_form_mc.mouseChildren = false;
if (param1 == 0)
{
_messBox_mc.visible = true;
_messBox_mc.gotoAndStop(2);
}
if (param1 == 1)
{
_messBox_mc.visible = true;
_messBox_mc.gotoAndStop(3);
}
if (param1 == 2)
{
_messBox_mc.visible = true;
_messBox_mc.gotoAndStop(1);
}
return;
}// end function
private function $send() : void
{
var loader:URLLoader;
var req:URLRequest;
var variables:URLVariables;
var onSendComplete:Function;
onSendComplete = function (event:Event) : void
{
var _loc_2:String = null;
loader.removeEventListener(Event.COMPLETE, onSendComplete);
_loc_2 = URLVariables(event.target.data).retval;
if (_loc_2 == "1")
{
_target.stage.focus = null;
showMessageBox(2);
}
else
{
showMessageBox(0);
}
return;
}// end function
;
if (_isPreview == true)
{
_target.stage.focus = null;
showMessageBox(2);
return;
}
loader = new URLLoader();
req = new URLRequest(_file_url);
variables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
variables.php_mail = _email_txt.getText();
variables.php_subject = _subject_txt.getText();
variables.php_message = _message_txt.getText();
variables.php_name = _name_txt.getText();
req.data = variables;
loader.addEventListener(Event.COMPLETE, onSendComplete);
showMessageBox(1);
loader.load(req);
return;
}// end function
private function reset(event:MouseEvent = null) : void
{
_email_txt.reset();
_name_txt.reset();
_message_txt.reset();
_subject_txt.reset();
_error_txt.text = "";
return;
}// end function
private function clodeMessageBox(event:MouseEvent = null) : void
{
_messBox_mc.visible = false;
_form_mc.mouseEnabled = true;
_form_mc.mouseChildren = true;
return;
}// end function
}
}
答案 0 :(得分:0)
好的我修好了
变量的正确名称是:
....
variables.php_mail = _email_txt.getText();
variables.php_subject = _subject_txt.getText();
variables.php_message = _message_txt.getText();
variables.php_name = _name_txt.getText();
....
所以de php代码是:
<?php
$to = "myemail@gmail.com";
$name = $_REQUEST['php_name'] ;
$message = $_REQUEST['php_message'] ;
$subject = $_REQUEST['php_subject'] ;
$from = $_REQUEST['php_mail'] ;
mail($to, $name, $message,$subject,$from);
echo "Mail Sent.";
?>