php教程|php手册
ajax,php,实现,写入,数据库,首先,需要,一个,带,输入,表格,复制,代码,如下,change,this,tem
php教程-php手册
首先需要一个带输入表格.
vip电影cms源码,ubuntu输不了汉语,修改tomcat的版本号,爬虫抓取目标,php前端后端教程交流教程,智慧通 seolzw
复制代码 代码如下:
新闻cms源码,Ubuntu支持无线键盘,项目部署在tomcat位置,爬虫怎么翻译,php教程视频讲解交流,seo软件市场lzw
<!–
To change this template, choose Tools | Templates
and open the template in the editor.
–>
单页导航源码带后台,vscode项目怎么运行,ubuntu原版下载,tomcat 项目冲突,sqlite字符串位置,java写的多源爬虫影视,php 字符串出现的位置,滨州资深seo平台,dede网站模板替换,网页源代码显示不一样,ace admin 模板lzw
知识点
需要js来处理提交数据到服务器上以及从服务器获取提交后的返回数据. submit.js代码如:
复制代码 代码如下:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
var xmlHttp;
function getValue(){
alert(“getvaluel”);
var question =document.insertForm.question.value;
// alert(question);
var answer = document.insertForm.answer.value;
// alert(answer);
submit(question,answer);
};
function submit(question,answer){
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert (“Your browser does not support AJAX!”);
return;
}
xmlHttp.onreadystatechange =function(){
if(xmlHttp.readyState ==4){
alert(xmlHttp.responseText);
}
};
var url = “insert1.php”;
xmlHttp.open(“post”,url,true);
xmlHttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded; charset=utf-8″);
xmlHttp.send(“question=”+question+”&answer=”+answer);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
}
return xmlHttp;
}
然后PHP处理界面,负责跟服务器交换数据
复制代码 代码如下:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//echo $_POST[“question”];
//echo $_POST[“answer”];
$q =$_POST[‘question’];
$a = $_POST[‘answer’];
//$q=’qq’;
//$a=”a”;
$con = mysql_connect(“localhost”,”joe”,”123″);
if (!$con)
{
//die(‘Could not connect: ‘ . mysql_error());
echo ‘Could not connect: ‘ . mysql_error();
}
mysql_select_db(“joe”,$con);
mysql_query(“INSERT INTO message VALUES (‘$q’, ‘$a’, ‘无’)”);
mysql_close($con);
echo “输入成功”;
?>