php论坛通用在网站首页登入无跳转解决方法
这里的对象主要针对那些对论坛本身不是很了解,而又想实现这种无跳转登入的功能。这个思想对所有作的好的php论坛都通用。首先介绍以下文件分布。网站根目录下index.php和bbs是同一级别,本例以phpbb为例:
|
|――images
|――bbs
|――login.php
|――login1.php
|――
|――index.php
|――123.php
我这样处理的复制login.php新建一个login1.php文件。其中login1.php和login.php内容完全一样,当然对于不同的论坛你也可以修改一些东西。
login1.php的出现很高明,请大家想象以下原因。
然后在index.php中包含了这样一个文件login.html,以下是大致的代码:
[php] <!--<?php if(empty($sid)){
print <<<EOT
-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 >
<TBODY>
<TR>
<TD height=10 bgcolor="#FFFFFF"></TD>
</TR>
<TR>
<TD height="26" background="images/index_01.gif" ><div align="center"><font size="2"><strong>祅嘲</strong></font>
</div></TD>
</TR>
<TR>
<TD height="5"> </TD>
</TR>
<TR>
<TD vAlign=top>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width='100%' border='0' cellspacing='0' cellpadding='0'><form action='./bbs/login1.php' method='post' name='UserLogin' onSubmit='return CheckForm();'>
<tr><td height='25' align='right'><font size="2">ノめ:</font></td><td height='25'><input name="username" class="post" type='text' id='UserName' size='10' maxlength='20'></td></tr>
<tr><td height='25' align='right'><font size="2">盞 絏: </font></td><td height='25'><input type="password" name="password" class="post" size='10' maxlength='20'></td></tr>
<tr align='center'><td height='25' colspan='2'><input type="submit" name="login" class="mainoption" value=' 祅嘲 '>
<input type="hidden" name="redirect" value='../index.php'>
<input name='Reset' type='reset' id='Reset' value=' 睲埃 '></td></tr>
<tr><td height='20' align='center' colspan='2'><a href='./bbs/profile.php' target='_blank'><font size="2">穝ノめ猔</font></a> <a href='GetPassword.php' target='_blank'><font size="2">а癘盞絏</font></a></td></tr></form></table>
<script language=javascript>
function CheckForm()
{
if(document.UserLogin.UserName.value=="")
{
alert("请输入用户名□");
document.UserLogin.UserName.focus();
return false;
}
if(document.UserLogin.Password.value == "")
{
alert("请输入密码□");
document.UserLogin.Password.focus();
return false;
}
}
</script>
</td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD height="5"> </TD>
</TR>
<TR>
<TD height=1 colspan="2" background=images/naSzarym.gif><IMG height=1 src="images/1x1_pix.gif" width=10></TD></TR>
</TBODY>
</TABLE>
<!--
EOT;
}
?>
<?php if($sid){print <<<EOT
-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 >
<TBODY>
<TR>
<TD height=10 bgcolor="#FFFFFF"></TD>
</TR>
<TR>
<TD height="26" background="images/index_01.gif" ><div align="center"><font size="2"><strong>祅嘲</strong></font>
</div></TD>
</TR>
<TR>
<TD height="5"> </TD>
</TR>
<TR>
<TD vAlign=top>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width='100%' border='0' cellspacing='0' cellpadding='0'><form action='./bbs/login1.php' method='post' name='UserLogin' onSubmit='return CheckForm();'>
<tr><td height='25' align='right' width='120'><font size="2">舧ㄓ</font></td><td height='25'></td></tr>
<tr><td height='25' align='right' width='140'><font size="2">竒Θ祅</font></td><td height='25'></td></tr>
<tr><td height='20' align='center' colspan='2'><a href='./bbs/index.php' target='_blank'><font size="2">祅bbs</font></a> <a href='GetPassword.php' target='_blank'><font size="2"></font></a></td></tr></form></table>
<script language=javascript>
function CheckForm()
{
if(document.UserLogin.UserName.value=="")
{
alert("请输入用户名□");
document.UserLogin.UserName.focus();
return false;
}
if(document.UserLogin.Password.value == "")
{
alert("请输入密码□");
document.UserLogin.Password.focus();
return false;
}
}
</script>
</td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD height="5"> </TD>
</TR>
<TR>
<TD height=1 colspan="2" background=images/naSzarym.gif><IMG height=1 src="images/1x1_pix.gif" width=10></TD></TR>
</TBODY>
</TABLE>
<!--
EOT;
}
?>-->
[/php]
[color=Red]注意了,朋友们<input type="hidden" name="redirect" value='../index.php'> 这个又是一个关键,其他的可以不看。[/color]
以下是使用,不讨论你没有注册的情况,这些谁都会处理。
使用一个正确的帐号登入在index.php页得到以下参数index.php?sid=xxxxxx
我以上的程序可以告诉你已经成功登入。
然后
在index.php开头我这样写
[php]if($sid){
Session_Start();
$_SESSION['adminname']=c1a1o1;
} [/php]
在123.php我这样引用
<?
session_start();
if($_SESSION['adminname'])
{
$sid=c1a1o1;
}?>
成功!
大致实现了需要的功能!
再重复以下句子,请大家看看!顺便批皮!
[color=Red]注意了,朋友们<input type="hidden" name="redirect" value='../index.php'> 这个又是一个关键,其他的可以不看。[/color]
其他论坛我测试了phpwind思路差不多,差异的原因是我对phpwind了解一些。 只一句,就是phpwind隐藏域中的redirect变量传递,对吧? 是的,哈哈!但是思想可以的! 为啥贴这么多代码.看晕我了,到头来就一句有用了,这不是有心整理我嘛 哈哈,最近在研究代码,:handshake[url=http://bearecycleman.blogspot.com/2010/11/pp-woven-bag.html][size=0.1px][color=white]PP Woven Bag環保袋知識[/color][/size][/url][url=http://jade3link.pixnet.net/blog/post/16586849][size=0.1px][color=white]淨化空氣的植物好幫手[/color][/size][/url][url=http://blog.udn.com/jadeballet/1914901][size=0.1px][color=white]芭蕾-腳尖上的藝術[/color][/size][/url][url=http://blog.qooza.hk/jianfei?eid=21079584][size=0.1px][color=white]中醫穴位減肥法[/color][/size][/url][url=http://blog.sina.com.tw/your3x/article.php?pbgid=79323&entryid=622494][size=0.1px][color=white]簡單生活之油菜花[/color][/size][/url][url=http://sale09.jugem.jp/?eid=3][size=0.1px][color=white]情系故鄉[/color][/size][/url][url=http://showsale.blogage.de/entries/2009/7/13/---][size=0.1px][color=white]人生中寬容的最高境界[/color][/size][/url][url=http://blog.24reader.com/bb86/2009/06/03/the-way/][size=0.1px][color=white]我自有辦法[/color][/size][/url][url=http://showsale.blog126.fc2.com/blog-entry-2.html][size=0.1px][color=white]兩種婚姻[/color][/size][/url][url=http://cleanday.blogsome.com/2009/04/14/p3/][size=0.1px][color=white]從蓋頂顏色速辨法蘭西葡萄酒[/color][/size][/url][url=http://new3k.mee.nu/8][size=0.1px][color=white]秋季睡眠8大禁忌要繞開[/color][/size][/url][url=http://valentine.flowers-hk.com/?p=9][size=0.1px][color=white]一門心思走路[/color][/size][/url][url=http://blog.sandiegotown.com/showsale/?eid=24129][size=0.1px][color=white]暖瓶的哲理[/color][/size][/url][url=http://minibear.bloc.cat/post/18432/313494][size=0.1px][color=white]改變了自己才能改變世界[/color][/size][/url][url=http://jeffrey.biometric-fingerprint.com/?p=3][size=0.1px][color=white]Take A Minute to Think[/color][/size][/url][url=http://blog.tyc.edu.tw/b/new3k/post/6263/17335][size=0.1px][color=white]從喝酒模式看你是哪種女人[/color][/size][/url][url=http://showsale.blog.com/2009/07/11/soul/][size=0.1px][color=white]心靈的間奏[/color][/size][/url][url=http://sale09.ti-da.net/e2493716.html][size=0.1px][color=white]網路世界真奇妙[/color][/size][/url][url=http://cleanday.mie1.net/e125532.html][size=0.1px][color=white]南非葡萄酒標常見標識註解[/color][/size][/url][url=http://recyclewoman.mysinablog.com/index.php?op=ViewArticle&articleId=2513368][size=0.1px][color=white]如何辨別"綠色環保"家具[/color][/size][/url][url=http://bearecycleman.blogspot.com/2010/07/blog-post_20.html][size=0.1px][color=white]環保袋既省錢又環保[/color][/size][/url][url=http://www.pianocenter-hk.com/][size=0.1px][color=white]PIANO[/color][/size][/url] redirect一句搞定……
页:
[1]