帮助登录脚本 - 寻找快速回答! :) [英] Help with login script - Looking for a quick answer! :)
问题描述
我站在我在本地制作网站的位置,用作以后演示的产品。
网站内有登录,地址簿,信息中心和活动。 />
我的问题是应该在我的登录脚本中(因为,tilslut.php)突然停止工作100%。它的工作原理是我将从index.php登录,用户名Nicolaj,密码为123789456,但是当必须从下一页,check.php批准时,它会一直报告无效的用户名/密码。之后它应该被发送到页面,forside.php
如果你开始尝试从check.php报告错误时跳转到forside.php没有问题,但如果您在页面forside.php上注销。然后你无法访问任何其他页面。
能帮助我解决问题的人会产生问题吗? :)
(各页面的代码如下所示。)
Index.php
< pre lang =PHP> <?php
session_start();
$ _SESSION [' loggedin'] = true;
?>
< html >
< style type = text / css > @ import url(css.css); < / style >
< script >
函数msg()
{
alert( Kontakt din管理员p Nicolaj-Aaroe@live.dk!);
}
< / script >
< center > < br > ; < br > < br > < span class =code-keyword>< br >
< title > Familielogin ::登录< / title >
< font size = 200 color = 海军 > Familieside < < span class =code-leadattribute> / font > < br >
Velkommen til familielogin < br >
Log venligst ind!
< 表格 action = check.php 方法 = 发布 名称 = login >
B:< input 类型 = text value = 用户名 name = username / > < br >
K:< 输入 类型 = 密码 value = 密码 名称 = 密码 / > < ; br >
< 输入 type = 提交 name = login value = 记录 / > < / form >
< 输入 type = 按钮 name = glemt value = Glemt登录 onclick = msg() / >
< / form >
< / div > ;
< / html >
Check.php
< span class =code-pagedirective><?php
$ _SESSION [' errors'] = 0;
$ _SESSION [' loggedin'] = true;
include( config.php);
?>
<? php
if(isset($ _ POST [' login']));
{
$ username = $ _ POST [' username'];
$ password = $ _ POST [' password'];
$ username = stripslashes($ username);
$ password = stripslashes($ password);
$ username = mysql_real_escape_string($ username);
$ password = mysql_real_escape_string($ password);
$ sql = SELECT * FROM $ tbl WHERE username ='$ username'和password ='$ password 跨度>;
$ result = mysql_query($ sql);
$ count = mysql_num_rows($ result);
if($ count == 1){
$ _SESSION [' username '] = $ _POST [' username'];
header(' 位置:forside.php');
} 其他 {
echo < font color ='red'> < center>< br>< br>< br>< br> Forkert brugernavn eller密码< / font>;
}}
?>
< html >
< center > < br > < br > < br > < br >
< style type = text / css > @ import url(css.css ); < / style >
< class < span class =code-attribute> id = body >
< script >
函数goBack()
{
window.history.go(-1)
}
< / script >
< body >
< br > < br > < 按钮 onclick = goBack() > Gåtilbageogprøvige< / button > ;
< / body >
< / html >
Forside.php
<?php
session_start();
$ _SESSION [' loggedin'] = true;
if(isset($ _ SESSION [' username'])){
include(' tilslut.php');
?>
< style type = text / css > @ import url(css.css); < / style >
< meta http-equiv = 内容 - 输入 content = text / html; charset = UTF-8 >
< table style = width :100% >
< tr >
< td width = 50% > < font size = 5 颜色 = 海军 > < center > Familie Arrangementer < br > ; < br > < / font > < / td >
< td width = 50% align = right > < font size = 5 颜色 = 海军 > < center > Meddelsescenter < br > < br > < / font > < / td >
< / tr >
< tr >
< td > <? php
$ famarr = mysql_query( SELECT * FROM famarr ORDER by id DESC);
echo < table width ='100%'border ='1'align ='left'cellpadding ='0'cellspacing ='1'bgcolor ='#FFFFFF'>
< tr>
< th> ;导航< / th>
< th> Sted< / th>
< th> Dato< / th>
< / tr>;
while($ row = mysql_fetch_array($ famarr)){
echo < tr>;
echo < td>。 $ row [' navn']。 < / td>;
echo < td>。 $ row [' sted']。 < / td>;
echo < td>。 $ row [' dato']。 < / td>;
echo < / tr> 跨度>;
}
echo < /表>跨度>;
// mysql_close($ con);
?> < / td >
< td > <? php
$ result = mysql_query( SELECT * FROM beskeder ORDER by dato DESC);
while($ row = mysql_fetch_array($ result)){
echo < table width ='100%'border ='0'align ='right'cellpadding ='0'cellspacing ='1'bgcolor ='#CCCCCC'>
< tr>
< td>< table width ='100%'border ='0'cellpadding ='3'cellspacing ='1'bgcolor ='#FFFFFF'>
< ; tr>
< td> Dato< / td>
< td>:< / td>
< td>。 $ row [' dato']。 < / td>
< / tr>
< tr>
< td width ='50'> Navn< / td>
< td width ='14'>:< / td>
< td width ='357'> 。 $ row [' navn']。 < / td>
< / tr>
< td valign ='top '> Besked< / td>
< td valign ='top'>:< / td>
< td style ='word-break:break-all;'> 。 $ row [' besked']。 < / td>
< / tr>
< / table>< br>< / td>
< / tr>
< / table>;
echo < /跨度>;
}
echo 跨度>;
?> < / td >
< td > < / td >
< / tr >
< tr >
< td > < center > < 按钮 onclick = window.location.href =' famarr / fam.php' > ; Tilfoej安排< / button > ; < / td >
< td > < center > < 按钮 onclick = window.location.href =' add / add.php' > Adressekarkotek < / button > < span class =code-keyword>< 按钮 onclick = window.location.href =' forum.php' > Skriv en besked < / button > < 按钮 onclick = window.location.href =' logud.php' > 记录< / button > < / table > < / td >
< / tr >
< / table >
<? php
} 其他 {
?>
< center > < h2 > < font color = 海军 > < br > < br > < br > < ; br > Du er ikke logget ind,UPS!< / font > < / h2 > < / center >
<? php
}
?>
< br $>
tilslut.php
<?php
$ _SESSION [' userName'] = ' ';
$ host = 本地主机跨度>;
$ user = root跨度>;
$ pass = ;
$ db = famarr跨度>;
mysql_connect( $ host, $ user, $ pass)或死亡( Kan ikke forbinde til databasen。:( );
mysql_select_db( $ db)或死亡( Kan ikke finde databasen。:();
error_reporting(E_ALL);
ini_set(' display_errors',' < span class =code-string> 1');
?>
_SESSION [' loggedin'] = true;
?>
< html >
< style 类型 = text / css > @ import url(css.css); < / style >
< script >
function msg()
{
alert( Kontakt dinadministratorpåNicolaj-Aaroe @ live没有自动跳转跨度>)!;
}
< / script >
< center > < br > ; < br > < br > < span class =code-keyword>< br >
< title > Familielogin ::登录< / title >
< font size = 200 color = navy\">Familieside<< span class=\"code-leadattribute\">/font><br>
Velkommen til familielogin< br>
Log venligst ind! $b$ b
<form action=\"check.php\" method=\"post\" name=\"login\">
B: <input type=\"text\" value=\"username\" name=\"username\"/><br>
K: <input type=\"password\" value=\"password\" name=\"password\"/><br>
<input type=\"submit\" name=\"login\" value=\"Log ind\"/></form>
<input type=\"button\" name=\"glemt\" value=\"Glemt Login\" onclick=\"msg()\"/>
</form>
</div>
</html>
Check.php
<?php
_SESSION['errors']=0;
_SESSION['loggedin'] = true;
include(\"config.php\");
?>
<?php
if(isset(
I stand in the position where i have made a website locally to be used as a product to a later presentation.
The website within keeps login, address book, message center and events.
My problem is should in my login script (Since, tilslut.php) suddenly stopped working 100%. It works in the sense where i will be logged in from index.php, with the username "Nicolaj" with the password "123789456", but it keeps reporting invalid username / password when it must be approved from next page, check.php, after which it should be send to the page, forside.php
If you start to try to jump from check.php when it reported errors and on to forside.php there is no problem, but if you log out on the page forside.php. Then you can't access any of the other pages.
Someone who can help me with what it is that creates the problem? :)
(The codes for the various pages are listed below.)
Index.php
<?php
session_start();
$_SESSION['loggedin'] = true;
?>
<html>
<style type="text/css">@import url(css.css);</style>
<script>
function msg()
{
alert("Kontakt din administrator på Nicolaj-Aaroe@live.dk!");
}
</script>
<center><br><br><br><br>
<title>Familielogin:: LOGIN</title>
<font size="200" color="navy">Familieside</font><br>
Velkommen til familielogin<br>
Log venligst ind!
<form action="check.php" method="post" name="login">
B: <input type="text" value="username" name="username"/><br>
K: <input type="password" value="password" name="password"/><br>
<input type="submit" name="login" value="Log ind"/></form>
<input type="button" name="glemt" value="Glemt Login" onclick="msg()"/>
</form>
</div>
</html>
Check.php
<?php
$_SESSION['errors']=0;
$_SESSION['loggedin'] = true;
include("config.php");
?>
<?php
if(isset($_POST['login']));
{
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1) {
$_SESSION['username'] = $_POST['username'];
header('Location: forside.php');
} else {
echo "<font color='red'><center><br><br><br><br>Forkert brugernavn eller password</font>";
} }
?>
<html>
<center><br><br><br><br>
<style type="text/css">@import url(css.css);</style>
<class id="body">
<script>
function goBack()
{
window.history.go(-1)
}
</script>
<body>
<br><br><button onclick="goBack()">Gå tilbage og prøv igen</button>
</body>
</html>
Forside.php
<?php
session_start();
$_SESSION['loggedin'] = true;
if(isset($_SESSION['username'])) {
include('tilslut.php');
?>
<style type="text/css">@import url(css.css);</style>
<meta http-equiv="Content-Type" content="text/html;charset="UTF-8">
<table style="width:100%">
<tr>
<td width="50%"><font size="5" color="navy"><center>Familie Arrangementer<br><br></font></td>
<td width="50%" align=right><font size="5" color="navy"><center>Meddelsescenter<br><br></font></td>
</tr>
<tr>
<td><?php
$famarr = mysql_query("SELECT * FROM famarr ORDER by id DESC");
echo "<table width='100%' border='1' align='left' cellpadding='0' cellspacing='1' bgcolor='#FFFFFF'>
<tr>
<th>Navn</th>
<th>Sted</th>
<th>Dato</th>
</tr>";
while($row = mysql_fetch_array($famarr)) {
echo "<tr>";
echo "<td>" . $row['navn'] . "</td>";
echo "<td>" . $row['sted'] . "</td>";
echo "<td>" . $row['dato'] . "</td>";
echo "</tr>";
}
echo "</table>";
//mysql_close($con);
?></td>
<td><?php
$result = mysql_query("SELECT * FROM beskeder ORDER by dato DESC");
while($row = mysql_fetch_array($result)) {
echo "<table width='100%' border='0' align='right' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>
<tr>
<td><table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'>
<tr>
<td>Dato</td>
<td>:</td>
<td>" . $row['dato'] . "</td>
</tr>
<tr>
<td width='50'>Navn</td>
<td width='14'>:</td>
<td width='357'>" . $row['navn'] . "</td>
</tr>
<td valign='top'>Besked</td>
<td valign='top'>:</td>
<td style='word-break:break-all;'>" . $row['besked'] . "</td>
</tr>
</table><br></td>
</tr>
</table>";
echo "";
}
echo "";
?></td>
<td></td>
</tr>
<tr>
<td><center><button onclick=window.location.href='famarr/fam.php'>Tilfoej arrangement</button></td>
<td><center><button onclick=window.location.href='add/add.php'>Adressekarkotek</button> <button onclick=window.location.href='forum.php'>Skriv en besked</button> <button onclick=window.location.href='logud.php'>Log ud</button></table></td>
</tr>
</table>
<?php
} else {
?>
<center><h2><font color="navy"><br><br><br><br>Du er ikke logget ind, UPS!</font></h2></center>
<?php
}
?>
tilslut.php
<?php
$_SESSION['userName'] = '';
$host = "localhost";
$user = "root";
$pass = "";
$db = "famarr";
mysql_connect("$host", "$user", "$pass")or die("Kan ikke forbinde til databasen. :(");
mysql_select_db("$db")or die("Kan ikke finde databasen. :(");
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
_SESSION['loggedin'] = true; ?> <html> <style type="text/css">@import url(css.css);</style> <script> function msg() { alert("Kontakt din administrator på Nicolaj-Aaroe@live.dk!"); } </script> <center><br><br><br><br> <title>Familielogin:: LOGIN</title> <font size="200" color="navy">Familieside</font><br> Velkommen til familielogin<br> Log venligst ind! <form action="check.php" method="post" name="login"> B: <input type="text" value="username" name="username"/><br> K: <input type="password" value="password" name="password"/><br> <input type="submit" name="login" value="Log ind"/></form> <input type="button" name="glemt" value="Glemt Login" onclick="msg()"/> </form> </div> </html>
Check.php
<?php
_SESSION['errors']=0;
_SESSION['loggedin'] = true; include("config.php"); ?> <?php if(isset(
这篇关于帮助登录脚本 - 寻找快速回答! :)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!