JQuery打造PHP的AJAX表单提交实例
本实例只利用到JQuery类库本身的函数和功能,不需要第三方插件的支持。另外,所有表单信息都是利用PHPMailer类库邮件的形式发送给管理员。如果你对JQuery的基本语法还不是很熟悉,请搜索本站的教程资源。如果你对PHPMailer用法不熟悉,请查看本站的另一篇文章《使用PHPMailer类库发送电子邮件》。
第一步,创建一个表单HTML页面
这里,我们只展示主要的表单部分HTML结构代码:
<div id="contact_form">
<form name="contact" method="post" action="">
<fieldset>
<label for="name" id="name_label">姓名</label>
<input type="text" name="name" id="name" size="30" value="" class="text-input" />
<label class="error" for="name" id="name_error">此项必填</label>
<label for="email" id="email_label">您的Email</label>
<input type="text" name="email" id="email" size="30" value="" class="text-input" />
<label class="error" for="email" id="email_error">此项必填</label>
<label for="phone" id="phone_label">您的联系电话</label>
<input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
<label class="error" for="phone" id="phone_error">此项必填</label>
&
相关文档:
php版:
<?php
$cookie_file = fopen('cookie.txt','w');//dirname(__FILE__)."/cookie_".md5(basename(__FILE__)).".txt"; // 设置Cookie文件保存路径及文件名
function vlogin($url,$data){ // 模拟登录获取Cookie函数
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($cur ......
1. 建立和关闭连接
1) mysql_connect()
resource mysql_connect([string hostname [:port][:/path/to/socket][,string username] [,string password]])
所有参数都是可选的
举例:
@mysql_connect("localhost", "user", "password")
......
<?php
/*
* Created on 2008-10-25
*
* developer by Alex.do QQ:20779512
* PHP 5.0
*/
class mdbClass {
var $dbPath = 'database/#123123#.mdb'; //数据库路径
var $tabName; & ......
相关参数:<textarea name=content>
模板调用符:$
提交新表单的时候用如下代码,结果完全正常:
<form name="frm_HelpMessageAdd" id="frm_HelpMessageAdd" action="manage.php" method="POST" enctype="multipart/form-data">
<input name="content" type="hidden" id="shopProduct_Intro"& ......
在现在各种黑客横行的时候,如何实现自己php代码安全,保证程序和服务器的安全是一个很重要的问题,我随便看了下关于php安全的资料,并不是很多,至少比asp少多了,呵呵,于是就想写点东西,来防止这些可能出现的情况。这里没有太深的技术含量,我只是比较简单的谈了谈。(以下操作如无具体说明,都是基于PHP+MySQL+Apache的 ......