Ich habe folgendes Script für ein User Control Panel erstellt:
PHP
<?php
include("connect.php");
echo "
<html>
<head>
<title>MrMonat Control Panel</title>
<style type='text/css' rel='stylesheet'>
<style type='text/css'>
body{
background-color: #004669;
color: #aaa;
font-family : Arial, Verdana, Helvetica, sans-serif;
font-size: 14px;
}
#main{
background-color: #666;
width: 970px;
margin-left: auto;
margin-right: auto;
padding: 15px;
margin-top: 0px;
text-align: left;
height: 600px;
text-align: center;
}
#text{
background-color: #282828;
width: 800px;
margin-left: auto;
margin-right: auto;
padding: 15px;
height: 550px;
margin-top: 13px;
text-align: left;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 14px;
color: #aaa;
}
a.backlink:link{
text-decoration: none;
color: #aaa;
}
a.backlink:visited{
text-decoration: none;
color: #aaa;
}
a.backlink:hover{
font-weight: bold;
color: #ddd;
}
</style>
</head>
<body bgcolor='#004669' link='#aaaaaa' vlink='#aaaaaa'>
<center><img width='1000px' src='http://mrmonat.mr.funpic.de/upload/wcf/images/Mein Style/headerneu.jpg'></img>
<div id='main'><div id='text'>
Eingeloggt als: <b>$user</b><p>
<form action='pwchange.php' method='POST'>
Aktuelles Passwort:<br>
<input type='password' name='oldpasswort' style='background-color:#aaa;'><p>
Neues Passwort:<br>
<input type='password' name='neupasswort1' style='background-color:#aaa;'><p>
Neues Passwort wiederholen:<br>
<input type='password' name='neupasswort2' style='background-color:#aaa;'><p>
<input type='submit' name='submit' value='Passwort ändern'>
</form>";
$oldpasswort = $_POST['oldpasswort'];
$neupasswort1 = $_POST['neupasswort1'];
$neupasswort2 = $_POST['neupasswort2'];
$submit = $_POST['submit'];
if($submit)
{
if($oldpasswort==$passwortR)
{
if($neupasswort1==$neupasswort2&&$neupasswort1!='')
{
}
else
{
echo "Die Passwörter stimmen nicht überein";
}
}
else
{
echo "Falsches Passwort";
}
}
echo "<p><a href='profil.php' class='backlink'>Profil anzeigen</a><br><a href='logout.php' class='backlink'>Ausloggen</a>
</div><font face=' Arial, Verdana, Helvetica, sans-serif;' color='#aaaaaa' >© Copyright 2010 by MrMonat</div></center>
</body>
</html> ";
?>
Alles anzeigen
Das ist die Datei, die das Passwort ändern soll. Aber wie? Ich habe keine Ahnung wie ich machen soll, das das Script das neue Passwort genau in der txt datei dahin schreibt wo das alte steht, und das alte überschreibt.
Weitere Fakten:
meine index datei sieht so aus:
PHP
<?php
session_start();
$name = $_POST['name'];
$passwort = $_POST['passwort'];
$submit = $_POST['submit'];
echo "
<html>
<head>
<title>MrMonat Control Panel</title>
<style type='text/css' rel='stylesheet'>
<style type='text/css'>
body{
background-color: #004669;
color: #aaa;
font-family : Arial, Verdana, Helvetica, sans-serif;
font-size: 14px;
}
#main{
background-color: #666;
width: 970px;
margin-left: auto;
margin-right: auto;
padding: 15px;
margin-top: 0px;
text-align: left;
height: 600px;
text-align: center;
}
#text{
background-color: #282828;
width: 800px;
margin-left: auto;
margin-right: auto;
padding: 15px;
height: 550px;
margin-top: 13px;
text-align: left;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 14px;
color: #aaa;
}
a.backlink:hover{
font-weight: bold;
color: #ddd;
}
a.backlink:link,a.backlink:visited{
text-decoration: none;
}
</style>
</head>
<body bgcolor='#004669'>
<center><img width='1000px' src='http://mrmonat.mr.funpic.de/upload/wcf/images/Mein Style/headerneu.jpg'></img>
<div id='main'><div id='text'>
<form action='index.php' method='POST'>
Username:<br>
<input type='text' name='name' style='background-color: #aaa;'><p>
Passwort:<br>
<input type='password' name='passwort' style='background-color: #aaa;'><p>
<input type='submit' name='submit' value='Login' style='background-color: #aaa;'>
</form>
";
if($submit)
{
$file = "C:/San Andreas/Scriptfiles/Accounts/$name.txt";
$handle = fopen($file,"r+") or die('Datei nicht gefunden');
$i = 1;
while(!feof($handle))
{
$line[$i] = fgets($handle,1000);
$i++;
}
list($a, $Money) = split("=", $line[2]);
list($a, $Respekt) = split("=", $line[19]);
list($a, $Level) = split("=",$line[18]);
list($a, $Frakt) = split("=",$line[14]);
list($a, $Rank) = split("=",$line[15]);
list($a, $passwortR) = split("=",$line[1]);
list($a, $Job) = split("=",$line[16]);
if($Frakt==1)
{
$Frakt="LSPD";
}
if($Frakt==0)
{
$Frakt="Zivilist";
}
if($Frakt==2)
{
$Frakt="Mafia";
}
if($Frakt==3)
{
$Frakt="SA:TT";
}
if($Frakt==4)
{
$Frakt="Fallschirmspringa";
}
if($Frakt==5)
{
$Frakt="Grove Street";
}
if($Job==1)
{
$Job="Drogenhändler";
}
if($Job==2)
{
$Job="Abschlepperfahrer";
}
if($Job==3)
{
$Job="Detektiv";
}
$passwortR = substr($passwortR,0,-2);
if($passwortR == $passwort)
{
$_SESSION['passwortR']=$passwortR;
$_SESSION['user']=$name;
$_SESSION['logged']=1;
$_SESSION['Money']=$Money;
$_SESSION['Respekt']=$Respekt;
$_SESSION['Level']=$Level;
$_SESSION['Frakt']=$Frakt;
$_SESSION['Rank']=$Rank;
$_SESSION['Job']=$Job;
$_SESSION['file']=$file;
//Header("Location: userpage.php");
echo '<meta http-equiv="refresh" content="0; URL=userpage.php">';
}
else
{
$_SESSION['logged']=0;
echo "Falsches Passwort";
}
}
echo "</div><font face=' Arial, Verdana, Helvetica, sans-serif;' color='#aaaaaa' >© Copyright 2010 by MrMonat</div></center>
</body>
</html> ";
?>
Alles anzeigen
Die Userdatei MrMonat.txt: