當前位置:首頁 » 編程語言 » htmlphp交互

htmlphp交互

發布時間: 2022-10-06 23:04:42

1. 一個php 文件與多個html文件如何進行交互

<?php

header("Content-type: text/html; charset=gb2312");

header("Pragma: no-cache");

header("Expires: 0");

@$action = $_REQUEST ['action'];

$sid = MyTool::generateId ();

if (! $action)

$action = "list";

Trace::debug ( $action );


if ($action == "save") {

$reply = $_REQUEST ['reply'];//獲取回復值

print_r($reply);

$id = $_REQUEST ['f_id'];

CourseService::updateApplyState($db,$id,TrainApply::STATUS_PASS);


$apply=CourseService::getTrainApply($db,$id);


$student=$apply->owner;

$trainId=$apply->train;


$train=CourseService::getTrainSchele($db,$trainId);


$pass_test=$train->test==""?0:-1;

$pass_judge=$train->judge==""?0:-1;

$pass_readrate=$train->readrate==""?0:-1;

$pass_feedback=$train->feedback==""?0:-1;


$mc = new MyCourse();

$mc->schele_id = $train->id;

$mc->course_id = $train->course_id;

$mc->user_id = $student;

$mc->type = $train->catalog;

$mc->state = MyCourse::STATE_WAITING;

$mc->pass_test = $pass_test;

$mc->pass_judge =$pass_judge ;

$mc->pass_feedback = $pass_feedback;

$mc->pass_readrate = $pass_readrate;

$mc->score = $train->score;

$mc->starttime = $train->starttime;

$mc->endtime = $train->endtime;

$mc->coursename = $train->name;

CourseService::save($db, $mc);


print"<script>alert('通過操作成功!');window.close();location.href='applyreply.php?action=list'</script>";

}

if ($action == "reject") {

$id = $_REQUEST ['f_id'];

$sql = "update t_train_apply set f_status=2 where f_id='".$id."'";

Trace::debug ( $sql );

$db->Execute ( $sql );

print"<script>alert('拒絕操作成功!');window.close();location.href='applyreply.php?action=list'</script>";

}

if ($action == "list") {

$pagination = new MyPagination(0,1);

$UserID = $_SESSION[AuthorizationHelper::SESSION_USER_KEY]['id'];

$as = CourseService::listApply($db,$pagination,null,null,null,$UserID);

//print_r($as);

?>

<!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=gb2312" />

<title>無標題文檔</title>


<?= HTMLTool::includeResource() ?>

<link href="../css/css.css" rel="stylesheet" type="text/css" />

<script language="JavaScript">

$(function() {

$('#tabs').tabs({spinner:'載入...',fx:{ opacity: 'toggle' },selected:2});

});

function passIt(id){

var url = '<?php print $_SERVER['PHP_SELF'] ?>';

var pars = 'action=pass&f_id='+id;

alert(url+"?"+pars);

// open(url+"?"+pars);

var myAjax = new Ajax.Request(

url,

{

method: 'get',

parameters: pars,

onComplete:done

});

afterPass(id);

}


function afterPass(id){

// alert(originalRequest.responseXML);

// var result = originalRequest.responseXML.getElementsByTagName("id");

// alert(result.length);

document.getElementById('button_'+id).style.display='none';

document.getElementById('status_'+id).innerHTML='通過';

}

function rejectIt(id){

var url = '<?php print $_SERVER['PHP_SELF'] ?>';

var pars = 'action=reject&f_id='+id;

//alert(url+"?"+pars);

var myAjax = new Ajax.Request(

url,

{

method: 'get',

parameters: pars,

onComplete:done

});

afterReject(id);

}


function afterReject(id){

// alert(originalRequest.responseXML);

// var result = originalRequest.responseXML.getElementsByTagName("id");

// alert(result.length);

document.getElementById('button_'+id).style.display="none";

document.getElementById('status_'+id).innerHTML="駁回";

}


function done(){

alert("操作成功");

}

</script>

</head>


<body >

<!-- 導航欄 -->

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="navigationbar" class="navigationbar">

<tr><td height="28" >您現在的位置: <a href="../welcom.php">首頁</a> >> <a href="#">考試管理</a> >>考試申請管理</td></tr>

</table>

<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">

<tr>

<td valign="top">

<table width="100%" border="0" cellpadding="1" cellspacing="1" class="listtable">

<thead>

<tr>

<td width="150">考試名稱</td>

<td>申請原因</td>

<td width="150">申請人</td>

<td width="130">申請時間</td>

<td width="80">狀態</td>

<td width="80">管理</td>

</tr>

</thead>

<?php

//foreach($as as $a){

//Trace::debug($a);

//$schele = CourseService::getTrainSchele($db,$a->train);

//$u = UserService::getUser($db,$a->owner);

?>

<tr>

<td><?= $schele->name ?></td>

<td><?= $a->name ?></td>

<td><?= $u->trueName ?></td>

<td><?= MyTool::formatDate($a->createtime)?></td>

<td><span id="status_<?= $a->id ?>"><?= TrainApply::$STATUS_ARRAY[$a->status]?></span></td>

<td>&nbsp;<span id="button_<?= $a->id ?>">

<?php if($a->status==TrainApply::STATUS_WAITING) {?>

<a href="?action=pass&f_id=<?= $a->id ?>">通過</a>&nbsp;

<a href="application_manage.php?action=reject&f_id=<?= $a->id ?>">拒絕</a>

<?php } ?>

</td>

</tr>

<?php //} ?>

</table>

<?php include($_SERVER['DOCUMENT_ROOT']."/train/common/pagination.php")?>

</td>

</tr>

</table>


</body>

</html>

<?php }?>

<?php if($action=="pass") {//回復

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>無標題文檔</title>


<?= HTMLTool::includeResource() ?>

<script >

$(document).ready(function(){

$("#commonForm").validate();

});

</script>

</head>


<body>


<table width="98%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_up"></td>

<td class="border_middle_up"><span class="pagetitle">建議回復</span></td>

<td class="border_right_up"></td>

</tr>

</table>

</td>

</tr>

<tr>

<td align="center">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_middle">&nbsp;</td>

<td align="center">

<form id="commonForm" method="post">

<input type="hidden" name="action" value="save"/>

<input type="hidden" name="id" value="<?php print $_REQUEST ['id']?>" />

<textarea class="required" rows="10" cols="120" name="reply" maxlength="500">您的建議已採納,謝謝參與</textarea><br>

<span class="btn_green"><span><button type="submit" id="sure">提 交</button></span></span>

</form>

</td>

<td class="border_right_middle">&nbsp;</td>

</tr>

</table>

</td>

</tr>

<tr>

<td><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_down"></td>

<td class="border_middle_down">&nbsp;</td>

<td class="border_right_down"></td>

</tr>

</table></td>

</tr>

</table>

</body>

</html>


<?php } ?>


  • 就是你要的效果,,看仔細點只看標簽與判斷就行

2. 下面一段關於HTML與PHP代碼交互用來顯示不同問候語的例子

<html>
<title>在不同的時間顯示不同的問候語</title>
<body><?php
date_default_timezone_set("Asia/Shanghai"); //設置默認時區
$h=date("H"); //取得一個表示小時的數字if($h<12){
echo"早上好!";
}else{
echo"您好!";
}
?>
</body>
</html>

3. php 和 html 交互問題。想讓php返回一個圖片網址,以便html來在輸出圖片。前端怎樣獲得php返回信息

你想讓前段知道solve.php輸出地圖片的地址?那得用ajax技術,不刷新頁面的情況下從資料庫取得內容,然後用js處理當前頁面內容,就行了。

<img src="solve.php"/>你要是說,src裡面可以是個程序地址嗎,那是可以的,很多網站的驗證碼就是這個原理,如1樓所說

4. HTML5表單與PHP交互

PHP文件,就是以.php結尾的文件,然後用web伺服器去解析,就行了

最簡單的,新建個文件,後綴改為 .php 往裡面直接寫內容就行

5. html與php交互的問題

瀏覽器發請求到伺服器 伺服器解析請求並提取數據 伺服器將數據轉換為html 伺服器把最後解析完成的html返給瀏覽器

6. php網頁交互問題

filesave.html

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>無標題文檔</title>
</head>
<body>
<formid="form1"name="upload"enctype="multipart/form-data"method="post"action="filesave.php">
<inputtype="hidden"name="MAX_FILE_SIZE"/>
<inputtype="file"name="file"/>
<inputtype="submit"name="Submit"value="提交"/>
</form>
</body>
</html>

filesave.php

<?php
Classupload
{
var$upload_name;
var$upload_tmp_address;
var$upload_server_name;
var$upload_filetype;
var$file_type;
var$file_server_address;
var$image_w=900;//要顯示圖片的寬
var$image_h=350;//要顯示圖片的高
var$upload_file_size;
var$upload_must_size=50000;//允許上傳文件的大小,自己設置
functionupload_file()
{
$this->upload_name=$_FILES["file"]["name"];//取得上傳文件名
$this->upload_filetype=$_FILES["file"]["type"];
$this->upload_server_name=date("Y_m_dH_i_s").$this->upload_name;
$this->upload_tmp_address=$_FILES["file"]["tmp_name"];//取得臨時地址
$this->file_type=array("image/gif","image/pjpeg");//允許上傳文件的類型
$this->upload_file_size=$_FILES["file"]["size"];//上傳文件的大小
if(in_array($this->upload_filetype,$this->file_type))
{if($this->upload_file_size<$this->upload_must_size)
{
echo("上傳成功,謝謝支持");
$this->file_server_address="D:usrwwwhtmlupload/".$this->upload_server_name;
move_uploaded_file($this->upload_tmp_address,$this->file_server_address);//從TEMP目錄移出
echo("<imgsrc=$this->file_server_addresswidth=$this->image_wheight=$this->image_h/>");//顯示圖片


}
else
{
echo("文件容量太大");
}
}
else
{
echo("不支持此文件類型,請重新選擇");
}

}

}
$dd=newupload;
$dd->upload_file();
?>

其實不需要三個文件兩個文件就能實現了

7. html怎麼使用ajax和php交互

用jqurey.min.js
$.post("php",function(data){
});

8. html與php通過ajax交互的問題,無法處理中文。

這個demo我復制下來運行挺好的,沒毛病

9. 如何用php與html實現交互,html應該如何寫是正常寫,還是要特殊處理

html裡麵包含php 就是<div><?php echo 「php」; ?></div>
php 裡面輸出html 就 <?php echo 「<a>html</a>」; ?>

你說的連接起來,交互是什麼意思?
如果要點擊一個連接 就跳到 php的話, 就是 <a href="1.php">php</a> 或者用form post
如果要點擊一個連接 然後從php得到信息的話,那麼就用ajax。那麼ajax的東西 去網路一下即可。

10. php與html交互。

你html頁面用ajax非同步請求php頁面,
然後php頁面對提交的數據驗證,將驗證信息封裝成一個json數據返回給html就行,
總之,就是你去了解一下ajax就很簡單

熱點內容
linuxselect阻塞 發布:2024-03-29 10:16:07 瀏覽:448
java喂狗 發布:2024-03-29 10:03:33 瀏覽:547
mcafee按訪問掃描 發布:2024-03-29 10:02:40 瀏覽:817
編譯成debug版本 發布:2024-03-29 09:06:55 瀏覽:885
wms伺服器地址 發布:2024-03-29 09:05:55 瀏覽:416
mep編程器 發布:2024-03-29 09:05:13 瀏覽:140
大小s我們一家訪問人 發布:2024-03-29 09:03:16 瀏覽:532
造物者編程 發布:2024-03-29 08:50:27 瀏覽:534
sql技能 發布:2024-03-29 08:50:23 瀏覽:56
希沃安卓下載安裝應用在哪裡 發布:2024-03-29 08:22:51 瀏覽:631