一些小東西有時候可能用得上!
1.得到客戶端IP位址
function getip(){ $tip = split(",", $tip = split(",", $tip = split(",", $tip $cip = $tip[0];
}
else
$cip = $ ip));
}
2.session控制問 getip();
/* 短期而言,系統預設需要支援cookie. */
if (!isset($_COOKIE) OOKIE['userid'];
if (!isset($_COOKIE['sid'])) return false;
以上返回false意味著用戶沒有登陸,頁面將跳轉至首頁(登陸頁). */
$query = "SELECT * FROM user WHERE query($query) ;
if ($row = $db->sql_fetchrow($result)){
* cookie傳送的sid和資料庫保存的不吻合 */
if ($row['lastloginip'] != $ip) return /* 是否要考慮 session的過期 問題呢? */
}
else return false; /* 沒有這個userid */
$ses ];
unset($row );
$islogin = true;
return true; */
function sesssion_end( $userid, $sid){
return true;
}
3.做選美? "Refresh:0;url=./"); //一秒刷新
?>
<script>alert('<?php <BR>require_once('mysql.php'); <BR>require_once ('functions.php'); <br>$db = new sql_db('localhost','root','','selectmm'); <br>$user_id = $_GET['user_id']; <> $ip = getip(); <BR>$deltime = time()-3600; //減去一小時 <BR>$sql = "delete from vote where time <1$time 🎜>$db->sql_query($sql); <br><br>$sql = "select ip from vote where ip='$ip' and user_id='$user_id'"; 過 <BR>$linkid=$db->sql_query($sql) or die(mysql_error()); <BR>$count=$db->sql_affectedrows(); <BR>if($count) <br>{ <br>echo "您已經投過票了!"; <BR>} <BR>else <BR>{ <BR>$sql = "update user set vote_count=vote_count 1 WHERE sqluser_id='$n_id'"; <BR>$count=$db->sql_affectedrows(); <BR>if($count) <BR>{ <BR> echo "成功投票! "; <BR> $sql = "insert into vote (`ip`,`user_id`,`time`) values ('$ip','$user_id','".time()."')";/ /投票成功就插入一筆記錄。 <BR> $db->sql_query($sql); <br><br>} <BR>else <BR>{ <BR> echo "投票失敗!"; <BR>} <br><br>} <BR>?>'); <BR>//history.back(); <BR></script>
4. smarty的搜尋程式
require_once('mysql.php');
$db = new sql_db('localhost','root','','','','',''new sql_db('localhost','root','','','','','' ');
require_once('functions.php');
require_once('session.php');
session_begin();
require('./Libs/Smarty.class .' );
$smarty = 新Smarty;
$title = "首頁";
$smarty->分配("islogin",$islogin);
$smarty->分配("islogin",$islogin);
$smarty->分配(「標題」 ,$標題);
$age=$_GET['age'];
$arr=explode(',',$age);
$y=date('Y ');
$md=日期('-m-d');
$begin=($y-$arr[1]).$md;
$end=($y-$ arr[0]) .$md;
$sql="select p.* from pic_info p,user u 其中p.user_id=u.user_id 和u.birthday 在'$begin' 和'$end' 之間分組u.user_id" ;
$link=$db->sql_query($sql) 或die(mysql_error());
$row = $db->sql_fetchrowset($link);
$ db->sql_freeresult() ;
$smarty->assign("pic",$row);
$smarty->display('index.tpl.htm');
?> ;
5.註冊程序
require('mysql.php');
$str=new sql_db('localhost','root','','serootmmmm ');
$METHOD = $_POST;
if (isset($METHOD['nickname']) && $METHOD['nickname'] != '')$nickname $METHOD['nickname'] != ''=$nickname $METHOD ;
else { echo "<script>alert("使用者暱稱不能為空。 ")</script>"; echo "<script>location="register.php"</script>"; }
if (isset($METHOD['password']) && strlen($METHOD['password '])>=6) $password = $METHOD['password'];
else { echo "<script>alert("密碼至少6位元")</script>"; echo ""; }
$password2 = $METHOD['password2'];
alert("兩次輸入密碼不一致")"; echo "<script>location="register.php"</script>"; }
if (isset($METHOD['name']) && $METHOD['name'] != '') $name = $METHOD['name'];
else { echo "<script>alert("使用者名稱無法為空白。")</script>" ; echo "<script>location="register.php"</script>"; }
$birthday=$METHOD['年'].$METHOD['月'].$METHOD['日'];
$stature = $METHOD['stature'];
$占星術= $METHOD['占星術』];
$METHOD['goodat'];
$work = $METHOD['work'];
$educate = $METHOD['educate'];
$address = $METHOD['address'];
$tel = $METHOD['tel'];
METHOD['email']) && $METHOD['email'] != '') $email = $METHOD['email'];
else {" echo "<script>alert(🎜> else {" echo "<script>alert(🎜>為空白) </script>"; echo "<script>location="register.php"</script>"; }
if (!eregi("^[0-9a-z.-_] @[0-9a -z.] .[a-z]$",$email)) { echo "<script>alert( "電子郵件格式不合法")</script>"; echo "<script>location="register.php"< /script>"; } <BR> $dian =$METHOD['dian']; <BR> if (isset($METHOD['myself']))$$& $METHOD[]]o = $METHOD['myself']; <BR> else { echo "<script>alert("用.....不能空")</script>"; echo "<script>location="register.php "</script>"; }
if(isset($METHOD['enounce'])&& $METHOD['enounce']!='')$enounce = $METHOD['enounce'];
(".....不能為空")"; echo "<script>location="register.php"</script>"; }
$query = 「 SELECT * FROM user WHERE nickname ='$nickname' or email='$email'”;
$result = $str->sql_query($query)or die(myno_error()); row = $str->sql_fetchrow($result))
{ echo "<script>alert("對不起,使用者已註冊")</script>"; echo "<script>location="register.php" </script>"; }
$password = md5($password);
$query = 「插入`用戶`(`暱稱`,`密碼`,`姓名`,`生日,``占星詞「插入`用戶`(`暱稱`,`密碼`,`姓名`,`生日」``占星占星` ,`血型`,`身材`,`擅長`,`工作`,`教育`,`家鄉`,`地址`,`電話`,`電子郵件`,`qq`,`dian`,`我自己` ,`說出`) VALUES('$暱稱','$密碼','$name ','$birthday','$astrology','$bloodtype','$stature','$goodat','$ work','$educate','$homeplace','$address','$tel ','$email','$qq','$dian','$myself','$enounce')";
if($str->sql_query($query))
$str->sql_close();
echo "<script>alert("恭喜你,並註冊成功")</script>";
echo "<script>location="login.php"</script>";
? >
6.提交參數JS 控制
echo "