導航:首頁 > 編程語言 > php頁面設計代碼

php頁面設計代碼

發布時間:2024-10-16 12:15:41

php如何生成HTML頁面 要詳細的生成過程代碼

很簡單,用ob_start壓制,然後保存到一個html頁面就可以了,寫了個小演示
訪問時在後面加參數 ?id=xxx xxx為任意數字,你把裡面的輸出換成你的動態頁面就可以了,代碼里有解釋

<?php
ob_start();

/*下面的內容就是你原來的動態頁面*/
$id=isset($_GET["id"])?$_GET["id"]:'';
if ($id!=''){
echo "原使用參數的頁面 參數為".$id."</br>已生成<a href=\"$id.html\">$id.html</a>";
}
/*結束*/

$info=ob_get_contents();
$file=fopen($id.'.html','w');
fwrite($file,$info);
fclose($file);
?>

Ⅱ PHP做一個用戶登錄頁面

index.html登錄頁面代碼如下:
<!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>
</head>

<body>
<form id="forms" name="forms" method="post" action="loginchk.php">
用戶名:<input type="text" id="uname" name="uname" value=""/><br/>
密碼:<input type="password" id="upass" name="upass" value=""/><br/>
<input type="submit" id="loginbtn" value="立即登錄"/>
<input type="reset" id="resetbtn" value="重新填寫"/>
</form>
</body>
</html>

loginchk.php 的PHP程序代碼如下:
<?php
$uname=trim($_REQUEST["uname"]);
$upass=trim($_REQUEST["upass"]);
if($uname=="admin"&&$upass=="admin")
{
echo "登錄成功";
}
else
{
echo "登錄失敗,<a href='index.html'>重新登錄</a>";
}
?>

以上只是一個簡單示例,真正的開始,需要考到很多因素,比如說登錄前有效性檢查,加入登錄驗證碼,程序需要連接資料庫進行用戶匹配等。
希望對你有幫助 。
如果使用資料庫進行進行匹配的話,PHP程序可以這樣改進一下。
<?php
$uname=trim($_REQUEST["uname"]);
$upass=trim($_REQUEST["upass"]);

$con = mysql_connect("localhost","root","root");
mysql_select_db("dbname", $con);
$result = mysql_query("select * from sers where uname='$uname' and upass='$upass'");
$rs = mysql_fetch_array($result);
if($rs)
{
echo "登錄成功";
}
else
{
echo "登錄失敗,<a href='index.html'>重新登錄</a>";
}
?>
不過你需要連接到你自己的指定的資料庫和數據表。

Ⅲ 求寫個比較簡單的php登陸頁面代碼

主頁面:index.php <form name="form1" action="login.php" method="post" onsubmit="return check()"><!--這里注意onclick的用法-->
賬號:<input name="adminAccount" type="text" />

密碼:<input type="password" name="adminPass" />

輸入驗證碼:<input type="text" name="validate" />
< br />
<input type="submit" value="登陸" /><input type="reset" value="重置">
</form>判斷頁面:login.php<?php
//再連庫判斷賬號密碼
require_once("../inc/dbconfig.php");
$adminAccount=$_POST['adminAccount'];
$adminPass=md5($_POST['adminPass']);
$sql="select * from admin where adminAccount='$adminAccount' and adminPass='$adminPass'";
$result=mysql_query($sql) or die($sql);
$rows=mysql_num_rows($result);
if($rows==0){
?>
<script language="javascript">
alert("管理員賬號密碼錯誤!");
window.location="index.php";
</script>
<?
exit();
}
//將管理員賬號賦值給session
$_SESSION['adminAccount']=$adminAccount;
?>
<script language="javascript">
window.location="command.php";
</script>配置文件自己來就行了!

Ⅳ php網頁怎麼編輯源代碼

現在這個頁面沒有具體代碼 只有兩句話
第一句 定義個常數 值=1
第二具 引用一個文件 叫做 load.php
你需要去修改 load.php 頁面的代碼 所有輸出應該到在那個頁面中。

Ⅳ 求這個PHP頁面如何加入代碼才能實現自動跳轉到其他網站

<?php
header('Location: http://www..com');//換成你想要跳至的網址

error_reporting(E_ERROR | E_PARSE | E_STRICT);

define('SITE_PATH', getcwd());
define('RUNTIME_ALLINONE', false);
define('NO_CACHE_RUNTIME', true);

require(SITE_PATH.'/core/sociax.php');

$App = new App();
$App->run();

Ⅵ 求一個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=gb2312" />
<title>這里是網站的標題</title>
<link href="css/index.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
font-size: 14px;
}
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.STYLE99 {

font-family: Georgia, "Times New Roman", Times, serif;
color: #FF00FF;
}
-->
</style></head>

<body>

<div id="bigbox" class="ceng">
<div id="banner" class="ceng"><img src="images/banner.gif" width="778" height="70" /></div>
<div id="main" class="ceng">
<form id="form1" name="form1" method="post" action="post.php">
<div id="log">
<div id="logxx"><span class="dazi">這里是網站的標題</span></div>
<div id="yonghu">用戶名:
<input name="user" type="text" id="user" />
</div>
<div id="mima">密 碼:
<input name="pass" type="password" id="pass" />
</div>
<div id="yanzheng">驗證碼:
<input name="yz" type="text" id="yz" size="8" maxlength="4" />
<?php
//$yzm = rand(1000, 9999 );
//echo $yzm;
$seedarray =microtime();
$seedstr =split(" ",$seedarray,5);
$seed =$seedstr[0]*10000;
//第二步:使用種子初始化隨機數發生器
srand($seed);
//第三步:生成指定范圍內的隨機數
$random =rand(1000,9999);
echo "<span class=\"STYLE99\">".$random."</span>";
?>
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $random ?>" />
</div>
<div id="tijiao">
<input type="submit" name="Submit" value="提交" />

<input type="reset" name="Submit2" value="重置" />
</div>
</div>
</form>
</div>
<?php include("buttom.php");?>
</div>

</body>
</html>

<!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>
<link href="css/index.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
font-size: 14px;
}
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>

<body>
<div id="bigbox" class="ceng">
<div id="banner" class="ceng"><img src="images/banner.gif" width="778" height="70" /></div>
<div id="main" class="ceng">

<div id="log">
<div id="logxx"><span class="dazi">這里是網站的標題</span></div>
<div id="yonghu">
<?php
function make_safe($variable) {
$variable = addslashes(trim($variable));
return $variable;
}
$user=make_safe($_REQUEST["user"]);
$pass=make_safe($_REQUEST["pass"]);
$yz=make_safe($_REQUEST["yz"]);
$yzma=make_safe($_REQUEST["hiddenField"]);

if ($yz == $yzma)
{
if ($user=="" or $pass=="" or $yz =="")
{
echo"你輸入的信息有空,請<a href=\"login.php\">"."返回"."</a>重新輸入";
}
else
{
mysql_connect("localhost","root","12345") /*請修改用戶名和密碼*/
or die("無法連接資料庫,請重來");
mysql_select_db("user")
or die("無法選擇資料庫,請重來");
mysql_query("SET NAMES 'gbk'");/*解決漢字*/
$row = mysql_fetch_assoc(mysql_query(" SELECT pass,xh FROM yh where name = '$user' and password = '$pass'"));
$mima=$row[password];

if($pass == $mima)
{
session_start();
$_SESSION['yhm']=$user;
echo "<script>alert('成功登陸')</script>";
echo "<script>window.location.href='a.php';</script>";
}
else
{
echo"你的用戶名或者密碼輸入錯誤,請<a href=\"login.php\">"."返回"."</a>";
}
}
}
else
{
echo"您輸入的驗證碼不正確!請<a href=\"login.php\">"."返回"."</a>";
}
?>

</div>
<div id="mima"></div>
<div id="yanzheng"></div>
<div id="tijiao"></div>
</div>

</div>
<?php include("buttom.php");?>
</div>
</body>
</html>

閱讀全文

與php頁面設計代碼相關的資料

熱點內容
點愛APP怎麼下載不了了 瀏覽:105
pr視頻生成文件夾能刪除嗎 瀏覽:715
香港雲伺服器1m帶寬嗎 瀏覽:366
如何打開老手機內存卡加密 瀏覽:850
單片機8腳5v 瀏覽:58
防止反編譯技術 瀏覽:489
網關的加密方式用哪個 瀏覽:232
加密便簽在哪裡找小米 瀏覽:527
對數函數的預演算法則 瀏覽:893
會計基礎教材pdf 瀏覽:408
怎麼用蘋果平板登安卓賬號王者 瀏覽:379
蘋果怎麼下rosi的app 瀏覽:488
單片機usb模塊作用 瀏覽:936
拿破崙傳pdf 瀏覽:884
Java7程序設計 瀏覽:400
黑馬程序員百度雲 瀏覽:559
java驗證碼識別演算法 瀏覽:758
單片機共陽極數碼管0到9重復 瀏覽:939
pdf如何圖片格式 瀏覽:382
龍虎榜接收數據器源碼 瀏覽:646