[1032]PHP入門
<<?php
//資料庫位址
define('_MYSQL_SERVER', "localhost");
//資料庫帳號
define('_MYSQL_NAME', "資料庫帳號");
//資料庫密碼
define('_MYSQL_PASSWD', "資料庫密碼");
//資料表庫名稱
define('_MYSQL_DBNAME', "資料表庫名稱");
error_reporting(-1);
/*-----------------------------------------------------*/
// 啟用 session
session_start();
$url=urlencode("http://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']) ;
if(isset($_GET['g2p'])){
$g2p=$_SESSION['g2p']=intval($_GET['g2p']);
}else{
$g2p=isset($_SESSION['g2p'])?intval($_SESSION['g2p']):"";
}
if(isset($_SESSION['uid']) and !empty($_SESSION['uid'])){
$login="
<div class='alert alert-info'>
<a href='index.php?op=logout' class='btn btn-danger btn-xs pull-right'>登出</a>
{$_SESSION['uname']}您好!
</div>
";
}else{
$login="
<div class='row' style='margin:10px;'>
<form action='index.php' method='post' class='form-horizontal' role='form'>
<div class='form-group'>
<label class='col-md-4 control-label'>帳號</label>
<div class='col-md-8'><input type='text' name='uname' class='form-control'></div>
</div>
<div class='form-group'>
<label class='col-md-4 control-label'>密碼</label>
<div class='col-md-8'><input type='password' name='passwd' class='form-control'></div>
</div>
<input type='hidden' name='op' value='login'>
<button type='submit' class='btn btn-success pull-right'>登入</button>
</form>
</div>
";
}
?>