• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

Problem mit Gästebuch

eismann90

New member
Hallo, auf meiner neuen Seite habe ich eine profil.php,gb.php,pm.php und bilderalbum.php für alle user.

Um auf ein Profil zu gelangen, benutze ich einfach POST
PHP:
<form method="post" action="profil.php">
<textarea name="user">eismann</textarea>
<input type="submit" name="button" value="eismann">
</form>

Am Anfang jeder Profilseite habe ich eine Abfrage eingebaut.
PHP:
if($_SESSION["besuch"] != $_REQUEST["user"] || $_SESSION["besuch"] != $_POST["user"]){
	if($_REQUEST["user"]){
		session_register("besuch");
		$_SESSION["besuch"] = $_REQUEST["user"];
	}
	else if($_POST["user"]){
		session_register("besuch");
		$_SESSION["besuch"] = $_REQUEST["user"];
	}
}

man selbst ist als $_SESSION["username"] registriert.


Mein Problem ist jetzt, wenn ich über die Userwahl auf mein eigenes Profil gehe kann ich ohne Probleme einen Gästebucheintrag tätigen, doch gehe ich auf ein anderes Profil, wird kein Eintrag getätigt. Das Verwirrt mich.

Hier mal das komplette Script für mein Gästebuch:
PHP:
<?php 
include ("check.php");
if($_SESSION["besuch"] != $_REQUEST["user"] || $_SESSION["besuch"] != $_POST["user"]){
	if($_REQUEST["user"]){
		session_register("besuch");
		$_SESSION["besuch"] = $_REQUEST["user"];
	}
	else if($_POST["user"]){
		session_register("besuch");
		$_SESSION["besuch"] = $_REQUEST["user"];
	}
}
?>
<html>
<head>
<title>PartyPiczSaar</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/inhalte.js"></script>
<style>
#eintraege textarea{display:none;}
#eintraege input{background:none;border-style:none;cursor:pointer;}
#eintraege input:hover{color:#F00;}
</style>
<script type="text/javascript">
function smiley(x,D,F){
D=document;F=D.getElementById('txt');
D.selection?(F.focus(),D.selection.createRange().text=x):(F.selectionStart||F.selectionStart===0)?F.value=F.value.substring(0,F.selectionStart)+x+F.value.substring(F.selectionEnd,F.value.length):F.value+=x}
function test(id){
e=document.getElementById(id);
if(e.style.display=='block'){e.style.display='none'}
else{e.style.display='block'}
}
</script>
</head>
<body>
<center>

<!--#Start Site-->

<div id="banner"></div>

<script type="text/javascript">navigation()</script>	

<div id="thema"><?php echo "<img style=\"float:left;margin:10px 0px 0px 10px;height:80px;\" src=\"User/".$_SESSION["besuch"]."/avater.jpg\">"; echo "<p>".$_SESSION["besuch"]."</p>"; ?></div>

<!--#Start Text-->
<div id="text">
	<div id="abstand">


		<!--#Start User_Nav--><style>
			input{cursor:pointer;}
			input:hover{color:#F00;}
			</style>
			<table style="float:right" cellspacing="0" cellpadding="0"><tr>
			<?php
			echo "<td><form method=\"post\" action=\"profil.php\"><textarea style=\"display:none;\" name=\"user\">".$_SESSION["besuch"]."</textarea><input style=\"border-style:none;background:none;\" type=\"submit\" name=\"button\" value=\"Profil\"></form></td>";
			echo "<td><form method=\"post\" action=\"gb.php\"><textarea style=\"display:none;\" name=\"user\">".$_SESSION["besuch"]."</textarea><input style=\"border-style:none;background:none;\" type=\"submit\" name=\"button\" value=\"Gästebuch\"></form></td>";
			echo "<td><form method=\"post\" action=\"pm.php\"><textarea style=\"display:none;\" name=\"user\">".$_SESSION["besuch"]."</textarea><input style=\"border-style:none;background:none;\" type=\"submit\" name=\"button\" value=\"Nachricht schreiben\"></form></td>";
			echo "<td><form method=\"post\" action=\"bilderalbum.php\"><textarea style=\"display:none;\" name=\"user\">".$_SESSION["besuch"]."</textarea><input style=\"border-style:none;background:none;\" type=\"submit\" name=\"button\" value=\"Bilderalbum\"></form></td>";
			?>
			</tr></table>
		<!--#Ende User_Nav_CSS-->


		<?php
		echo "<h1>Gästebuch von ".$_SESSION["besuch"]."</h1><br>";
		if($_POST["eintrag"]){
			$search = array(':-)',';-)',':-(',':liebe:',':bees:',':kuss:',':rock:',':lol:',':juhu:',':king:',':ey:',':g:',':doof:',':ne:',':arg:',':doh:',':megalach:',':schreck:',':kussje:',':krach:',':bussi:',':liebe2u:',':sauf2:',':schimpf:',':thx:',':depp:',':geil:',':super:',':ole:',':whe:',':/',':pop:',':beah:',':typischfrau:',':auslach:',':flunkyball:',':moins:',':-P',':lees:',':blubber:',':sheesha:');
			$replace = array(	'<img src="img/smilies/1.gif" alt=":-)" />','<img src="img/smilies/2.gif" alt=";-)" />','<img src="img/smilies/3.gif" alt=":-(" />','<img src="img/smilies/4.gif" alt=":liebe:" />','<img src="img/smilies/5.gif" alt=":bees:" />','<img src="img/smilies/6.gif" alt=":kuss:" />','<img src="img/smilies/7.gif" alt=":rock:" />','<img src="img/smilies/8.gif" alt=":lol:" />','<img src="img/smilies/9.gif" alt=":juhu:" />','<img src="img/smilies/10.gif" alt=":king:" />','<img src="img/smilies/11.gif" alt=":ey:" />','<img src="img/smilies/12.gif" alt=":g:" />','<img src="img/smilies/13.gif" alt=":doof:" />','<img src="img/smilies/14.gif" alt=":ne:" />','<img src="img/smilies/15.gif" alt=":arg:" />','<img src="img/smilies/16.gif" alt=":doh:" />','<img src="img/smilies/17.gif" alt=":megalach:" />','<img src="img/smilies/18.gif" alt=":schreck:" />','<img src="img/smilies/19.gif" alt=":kussje:" />','<img src="img/smilies/20.gif" alt=":krach:" />','<img src="img/smilies/21.gif" alt=":bussi:" />','<img src="img/smilies/22.gif" alt=":liebe2u:" />','<img src="img/smilies/23.gif" alt=":sauf2:" />','<img src="img/smilies/24.gif" alt=":schimpf:" />','<img src="img/smilies/25.gif" alt=":thx:" />','<img src="img/smilies/26.gif" alt=":depp:" />','<img src="img/smilies/27.gif" alt=":geil:" />','<img src="img/smilies/28.gif" alt=":super:" />','<img src="img/smilies/29.gif" alt=":ole:" />','<img src="img/smilies/30.gif" alt=":whe:" />','<img src="img/smilies/31.gif" alt=":/" />','<img src="img/smilies/32.gif" alt=":pop:" />','<img src="img/smilies/33.gif" alt=":beah:" />','<img src="img/smilies/34.gif" alt=":typischfrau:" />','<img src="img/smilies/35.gif" alt=":auslach:" />','<img src="img/smilies/36.gif" alt=":flunkyball:" />','<img src="img/smilies/37.gif" alt=":moins:" />','<img src="img/smilies/38.gif" alt=":-P" />','<img src="img/smilies/39.gif" alt=":lees:" />','<img src="img/smilies/40.gif" alt=":blubber:" />','<img src="img/smilies/41.gif" alt=":sheesha:" />');
			$tested = str_replace($search, $replace, $_POST["eintrag"]);
			$kommentare=file("User/".$_SESSION["besuch"]."/gb.txt");
			unset($kommentare[30]);
			$testedende=nl2br(preg_replace ('/(\\n|\\r|\\r\\n){2,}/','<br /><br />',$tested));
			$datenin = rtrim($testedende,'\n');
			$daten ="<div style=\"padding-left:20px\"><form method=\"post\" action=\"profil.php\"><textarea name=\"user\">".$_SESSION['username']."</textarea><input type=\"submit\" name=\"button\" value=\"".$_SESSION['username']." (".date("d.m.Y")." um ".date("H:i").")\"></form><p style=\"color:#000;font-size:13px;\">".$datenin."</p></div><br>";
			array_unshift($kommentare,$daten);
			$buch=fopen("User/".$_SESSION["besuch"]."/gb.txt","w");
			foreach ($kommentare as $kommentar) {
				fwrite($buch, $kommentar."\n"); 
			} 
			fclose($buch);

			$infodatei=file("User/".$_SESSION["besuch"]."/info.txt");
			$infoeintrag="Es gibt was Neues in deinem <a style=\"font-weight:bold;\" href=\"my_gb.php\">Gästebuch!</a><br>";
			$infoliste = array($infoeintrag,$infodatei[1]);
			$infobuch=fopen("User/".$_SESSION["besuch"]."/info.txt","w");
			foreach ($infoliste as $infolistelis) {
				fwrite($infobuch, $infolistelis."\n"); 
			}
			fclose($infobuch);

			echo "<div style=\"width:820px;margin:20px;padding:6px 10px;font-size:14px;color:#000;background:#CFC;border:1px solid #096;text-align:center;\">Dein Eintrag war erfolgreich!</div>";
		}
		?>


		<p><a href="javascript:test('schreiben')">Eintrag machen</a></p>
		<div id="schreiben" style="display:none;padding-left:20px;">
		<p><a href="javascript:test('smilies')">Smilies</a></p>
		<style>#smilies img{margin:2px;}</style>
		<div id="smilies" style="display:none;margin:6px 0px;">
<img src="img/smilies/1.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':-)')"><img src="img/smilies/2.gif" style="border-style:none;cursor:pointer;" onclick="smiley(';-)')"><img src="img/smilies/3.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':-(')"><img src="img/smilies/4.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':liebe:')"><img src="img/smilies/5.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':bees:')"><img src="img/smilies/6.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':kuss:')"><img src="img/smilies/7.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':rock:')"><img src="img/smilies/8.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':lol:')"><img src="img/smilies/9.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':juhu:')"><img src="img/smilies/10.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':king:')"><img src="img/smilies/11.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':ey:')"><img src="img/smilies/12.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':g:')"><img src="img/smilies/13.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':doof:')"><img src="img/smilies/14.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':ne:')"><img src="img/smilies/15.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':arg:')"><img src="img/smilies/16.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':doh:')"><img src="img/smilies/17.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':megalach:')"><img src="img/smilies/18.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':schreck:')"><img src="img/smilies/19.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':kussje:')"><img src="img/smilies/20.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':krach:')"><img src="img/smilies/21.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':bussi:')"><img src="img/smilies/22.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':liebe2u:')"><img src="img/smilies/23.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':sauf2:')"><img src="img/smilies/24.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':schimpf:')"><img src="img/smilies/25.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':thx:')"><img src="img/smilies/26.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':depp:')"><img src="img/smilies/27.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':geil:')"><img src="img/smilies/28.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':super:')"><img src="img/smilies/29.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':ole:')"><img src="img/smilies/30.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':whe:')"><img src="img/smilies/31.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':/')"><img src="img/smilies/32.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':pop:')"><img src="img/smilies/33.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':beah:')"><img src="img/smilies/34.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':typischfrau:')"><img src="img/smilies/35.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':auslach:')"><img src="img/smilies/36.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':flunkyball:')"><img src="img/smilies/37.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':moins:')"><img src="img/smilies/38.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':-P')"><img src="img/smilies/39.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':lees:')"><img src="img/smilies/40.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':blubber:')"><img src="img/smilies/41.gif" style="border-style:none;cursor:pointer;" onclick="smiley(':sheesha:')">
		</div>
		<form method="post" action="gb.php">
		<?php echo "<textarea style=\"display:none;\" name=\"user\">".$_SESSION["besuch"]."</textarea>"; ?>
		<textarea style="width:830px;height:140px;" name="eintrag" id="txt"></textarea><br>
		<input type="submit" name="button" value="Eintragen">
		</form>
		</div>


		<br>


		<div id="eintraege">
		<?php
		$gast = "User/".$_SESSION["besuch"]."/gb.txt"; 
		$adatei = fopen($gast,"r");
		fpassthru($adatei);
		?>
		</div>
	</div>
</div>
<!--#Ende Text-->

<script type="text/javascript">ende()</script>
<script type="text/javascript">zusatz()</script>

<!--#Ende Site-->

</center>
</body>
</html>

In check.php befindet sich nur eine Abfrage, ob man eingeloggt ist oder nicht.

Ich denke mir auch das ganze kann man noch schicker lösen aber in PHP bin ich noch recht neu :/

vielen dank schonmal fürs durchlesen
 
sind $_REQUEST["user"] und $_POST["user"] nicht genau die selbe Variable??

$_REQUEST solltest du nie verwenden! nimm nur $_POST und $_GET dann kommst du auch nicht durcheinander

und ja dein Code ist grausam, da hab ich auch null bock zu lesen :d, ich hoffe einfach mal, dass das schon der Fehler war/ist

mfg
 
Zurück
Oben