Fehler bei Adressen mit ?link=---

DeMoehn

Mitglied
Hi Leutz.
Ich hab eine Hauptseite (index.php).
In die Include ich auf button druck (http://www.MeineSite.de/index.php?link=home)
Die home.php.
Mein prob ist.
Jetzt include ich in die readNews noch die comments.php und die newComment.php
Das ganze sieht so aus.(http://www.MeineSite.de/index.php?link=readNews&id=1)
Wenn ich nun auf den Button in newComment.php drücke, dann springt der Browser zurück zum Anfang (http://www.MeineSite.de/index.php)
Hat einer eine Ahnung woran das liegt?
Was ich ändern kann?
 
Code:
<?php
include ("newssystem/config.inc.php");
mysql_connect($dbserver,$nutzer,$passwort);
$abfrage = "SELECT id, titel, name, mail, text, zeit, clicks FROM news WHERE id='$id'";
$res = mysql_db_query($dbname, $abfrage);
echo "<table width='460' border='0' bgcolor='white'>";
while ($reihe = mysql_fetch_object($res)){
$newClick = $reihe->clicks;
$newClick++;
$id = $reihe->id;
echo "<tr>";
echo "<td bgcolor='#cccccc'><b>$reihe->titel</b></td>";
$datumDB = $reihe->zeit;
$datum = date("d.m.Y",$datumDB);
echo "<td bgcolor='#cccccc'>$datum</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='top' bgcolor='#999999'>".nl2br($reihe->text)."</td>";
echo "<td valign='top' width='100' bgcolor='cccccc'>Nick:$reihe->name<br/><a href='mailto: '.$reihe->email>Mail</a><br/><a href='http://www.DeMoehn.de/homepage/index.php?link=home'>Back</a><br>Klicks($newClick)</td>";
echo "</tr>";
}
include("comments.php");
include("newComment.php"); // hier kommt das newComment
mysql_connect($dbserver,$nutzer,$passwort);
$insert = "UPDATE news SET clicks='$newClick' WHERE id='$id'";
$result = mysql_db_query($dbname, $insert);
?>
Also. Da Werden die news Ausgelesen
Code:
<?php
echo '<form action="newComment.php" method="post" name="entryComment">';
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><font size="1" face="Verdana,Helvetica,Arial,Geneva">Name:</font></td>';
echo '<td><input type="text" name="name" size="24"></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td><textarea name="text" rows="8" cols="55"></textarea></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td align="right"><input type="submit" name="senden" value="senden"></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
include ("newssystem/config.inc.php");
if($senden) {
$id = 1;
$datum = time();
$dataBase = "DB87590";
$connectIt = mysql_connect($dbserver,$nutzer,$passwort);
mysql_select_db($dataBase);
$insertIn = "INSERT INTO comments (name, text, zeit, newsId) VALUES ('$name', '$text', '$datum', '$id');";
$results = mysql_query($insertIn, $connectIt);
if($results) {
echo "oki";
}
}
?>
Hoffe du kannst was damit anfangen
PS: Hab ich schon gesagt das wenn ich einfach die NewComment.php aufrufe das es dann GEHT. Also der fehler liegt schon in der verbindung irgendwie
PPS: es scheint generell bei einbindungen nicht zu gehn. Muss aber doch irgendwie zu machen sein :(
 
Zuletzt bearbeitet:
1.
if($senden) {

if(isset($senden)) {

2.
if($results) {

if(isset($results)) {

PS poste noch die inde.php dann haben wirs, und können das Ding lösen! (bzw dein Hauptdokument)

Grüsse!

PS ich habe das Prob! Nicht!
PHP:
echo '<form action="newComment.php" method="post" name="entryComment">';

sondern
PHP:
echo '<form action="newComment.php?senden=1" method="post" name="entryComment">';

Du machst das über den Button finde ich nicht gut!

Versuchs mal
 
Zuletzt bearbeitet von einem Moderator:
Wo besteht der unterschied zwischen if(isset($senden)) {} und $senden
hier die Index.php
Code:
<html>
<?php
$_GET['link'];
if($link == "") {
$link = "home";
}
?>
<head>
<title>.:: DeMoehn.de <?php echo $link ?> ::.</title>
		<csscriptdict import>
			<script type="text/javascript" src="../../GeneratedItems/CSScriptLib.js"></script>
		</csscriptdict>
		<csactiondict>
			<script type="text/javascript"><!--
var preloadFlag = true;

// --></script>
		</csactiondict>
	</head>
<body bgcolor="#333333" text="black" link="black" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
<form name="menue" action="index.php" method="post" enctype="multipart/form-data">
			<table border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td align="center"><img src="myBanner.jpg" alt="" width="768" height="112"></td>
				</tr>
				<tr>
					<td align="center">
						<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
							<TR>
								<TD><a onmouseover="changeImages( /*CMP*/'Home',/*URL*/'bilder/over_03.gif');return true" onmouseout="changeImages( /*CMP*/'Home',/*URL*/'bilder/normal_03.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=home"><img SRC="bilder/normal_03.gif" name="Home" WIDTH=51 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'',/*URL*/'file:///OSX%20HD/Users/sebastian/Desktop/DeMoehn.de/Bilder/over_04.gif');return true" onmouseout="changeImages( /*CMP*/'',/*URL*/'file:///OSX%20HD/Users/sebastian/Desktop/DeMoehn.de/Bilder/normal_04.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=bilder"><img SRC="bilder/normal_04.gif" WIDTH=45 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_05',/*URL*/'bilder/over_05.gif');return true" onmouseout="changeImages( /*CMP*/'normal_05',/*URL*/'bilder/normal_05.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=flash"><IMG SRC="bilder/normal_05.gif" name="normal_05" WIDTH=44 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_06',/*URL*/'bilder/over_06.gif');return true" onmouseout="changeImages( /*CMP*/'normal_06',/*URL*/'bilder/normal_06.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=freunde"><IMG SRC="bilder/normal_06.gif" name="normal_06" WIDTH=60 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_07',/*URL*/'bilder/over_07.gif');return true" onmouseout="changeImages( /*CMP*/'normal_07',/*URL*/'bilder/normal_07.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=upload"><IMG SRC="bilder/normal_07.gif" name="normal_07" WIDTH=57 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_08',/*URL*/'bilder/over_08.gif');return true" onmouseout="changeImages( /*CMP*/'normal_08',/*URL*/'bilder/normal_08.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=scripte"><IMG SRC="bilder/normal_08.gif" name="normal_08" WIDTH=56 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_09',/*URL*/'bilder/over_09.gif');return true" onmouseout="changeImages( /*CMP*/'normal_09',/*URL*/'bilder/normal_09.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=schule"><IMG SRC="bilder/normal_09.gif" name="normal_09" WIDTH=52 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_10',/*URL*/'bilder/over_10.gif');return true" onmouseout="changeImages( /*CMP*/'normal_10',/*URL*/'bilder/normal_10.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=stuff"><IMG SRC="bilder/normal_10.gif" name="normal_10" WIDTH=46 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_11',/*URL*/'bilder/over_11.gif');return true" onmouseout="changeImages( /*CMP*/'normal_11',/*URL*/'bilder/normal_11.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=gaestebuch"><IMG SRC="bilder/normal_11.gif" name="normal_11" WIDTH=73 HEIGHT=23 ALT="" border="0"></a></TD>
							</TR>
						</TABLE>
					</td>
				</tr>
				<tr height="10">
					<td height="10"><spacer size="10" type="vertical"></td>
				</tr>
				<tr>
					<td>
						<div align="center">
						<?php
include ($link.".php");
?>
							</div>
					</td>
				</tr>
				<tr height="10">
					<td align="center" height="10"><spacer size="10" type="vertical"></td>
				</tr>
				<tr>
					<td align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="60" width="468">
							<param name="movie" value="noelle_fullsize.swf">
							<param name="quality" value="best">
							<param name="play" value="true">
							<embed height="60" pluginspage="http://www.macromedia.com/go/getflashplayer" src="noelle_fullsize.swf" type="application/x-shockwave-flash" width="468" quality="best" play="true"> 
						</object></td>
				</tr>
			</table>
		</form>

</body>

</html>
 
Diese kleinen Fehle solltest du unbedingt beheben

isset() prüft obe eine Variable gestzt ist

nicht gut
<?php
$_GET['link'];
if($link == "") {
$link = "home";
}
?>

<?php
if (isset($_GET['link']) { $link = $_GET['link']; }
if (isset($_POST['link']) { $link = $_POST['link']; }
if(!isset($link)) {
$link = "home";
}
?>

Dein Problem ist ganz einfach gesagt 1. Die falsche Prüfung und zweitens die Übergabe!

Du übergibst die werte über das form action
so wird der Wert über GET geholt. $_GET....

ist das Formular method Post und der Wert liegt in Eingabe oder Auswahlfeldern so holst du den Wert mittels $_POST


änder das ab und melde dich!


Angenommen jemand sendet das Formular ab


<?php
echo '<form action="newComment.php" method="post" name="entryComment">';
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><font size="1" face="Verdana,Helvetica,Arial,Geneva">Name:</font></td>';
echo '<td><input type="text" name="name" size="24"></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td><textarea name="text" rows="8" cols="55"></textarea></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td align="right"><input type="submit" name="senden" value="senden"></td>';
echo '</tr>';
echo '</table>';
echo '</form>';

so ist Method POST und du musst jetzt mittels $_POST[] ... holen.
 
Zuletzt bearbeitet von einem Moderator:
2.

Beachte hier das gleiche!


<?php
echo '<form action="newComment.php?senden=1" method="post" name="entryComment">';
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><font size="1" face="Verdana,Helvetica,Arial,Geneva">Name:</font></td>';
echo '<td><input type="text" name="name" size="24"></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td><textarea name="text" rows="8" cols="55"></textarea></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td align="right"><input type="submit" name="senden" value="senden"></td>';
echo '</tr>';
echo '</table>';
echo '</form>';

Schaumal das du senden=1 im form Tag setzt.

Somit prüfst du $senden=$_GET[senden];
Die inhaltlichen Formularfelder aber prüfst du mit $text=$_POST[text];
Da die Methode Post ist.

Grüsse!
 
Also, heißt das wenn im Form <method = "post"> steht, dann soll ich jetzt in der newComment.php so schreiben
Code:
<?php
echo '<form action="newComment.php" method="post" name="entryComment">';
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><font size="1" face="Verdana,Helvetica,Arial,Geneva">Name:</font></td>';
echo '<td><input type="text" name="name" size="24"></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td><textarea name="text" rows="8" cols="55"></textarea></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td align="right"><input type="submit" name="senden" value="senden"></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
include ("newssystem/config.inc.php");
if(isset($senden)) {
$name = $_POST['name'];
$text = $_POST['text'];
$id = 1;
$datum = time();
$dataBase = "DB87590";
$connectIt = mysql_connect($dbserver,$nutzer,$passwort);
mysql_select_db($dataBase);
$insertIn = "INSERT INTO comments (name, text, zeit, newsId) VALUES ('$name', '$text', '$datum', '$id');";
$results = mysql_query($insertIn, $connectIt);
if($results) {
echo "<a href='http:/www.DeMoehn.de/homepage/index.php?link=readNews'";
}
}
?>
Aber was hat das damit zu tun das der brwoser immer wieder auf den index zurück springt und nicht auf ?readNews&id=1 bleibt?
immer noch nich.
man man, k.A woran das liegen könnte ;.(
 
Also so:

PHP:
<html>
<?php
if (isset($_GET['link']) { $link = $_GET['link']; }
if (isset($_POST['link']) { $link = $_POST['link']; }
if(!isset($link)) {
$link = "home";
}
?>
<head>
<title>.:: DeMoehn.de <?php echo $link ?> ::.</title>
		<csscriptdict import>
			<script type="text/javascript" src="../../GeneratedItems/CSScriptLib.js"></script>
		</csscriptdict>
		<csactiondict>
			<script type="text/javascript"><!--
var preloadFlag = true;

// --></script>
		</csactiondict>
	</head>
<body bgcolor="#333333" text="black" link="black" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
<form name="menue" action="index.php" method="post" enctype="multipart/form-data">
			<table border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td align="center"><img src="myBanner.jpg" alt="" width="768" height="112"></td>
				</tr>
				<tr>
					<td align="center">
						<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
							<TR>
								<TD><a onmouseover="changeImages( /*CMP*/'Home',/*URL*/'bilder/over_03.gif');return true" onmouseout="changeImages( /*CMP*/'Home',/*URL*/'bilder/normal_03.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=home"><img SRC="bilder/normal_03.gif" name="Home" WIDTH=51 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'',/*URL*/'file:///OSX%20HD/Users/sebastian/Desktop/DeMoehn.de/Bilder/over_04.gif');return true" onmouseout="changeImages( /*CMP*/'',/*URL*/'file:///OSX%20HD/Users/sebastian/Desktop/DeMoehn.de/Bilder/normal_04.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=bilder"><img SRC="bilder/normal_04.gif" WIDTH=45 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_05',/*URL*/'bilder/over_05.gif');return true" onmouseout="changeImages( /*CMP*/'normal_05',/*URL*/'bilder/normal_05.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=flash"><IMG SRC="bilder/normal_05.gif" name="normal_05" WIDTH=44 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_06',/*URL*/'bilder/over_06.gif');return true" onmouseout="changeImages( /*CMP*/'normal_06',/*URL*/'bilder/normal_06.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=freunde"><IMG SRC="bilder/normal_06.gif" name="normal_06" WIDTH=60 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_07',/*URL*/'bilder/over_07.gif');return true" onmouseout="changeImages( /*CMP*/'normal_07',/*URL*/'bilder/normal_07.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=upload"><IMG SRC="bilder/normal_07.gif" name="normal_07" WIDTH=57 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_08',/*URL*/'bilder/over_08.gif');return true" onmouseout="changeImages( /*CMP*/'normal_08',/*URL*/'bilder/normal_08.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=scripte"><IMG SRC="bilder/normal_08.gif" name="normal_08" WIDTH=56 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_09',/*URL*/'bilder/over_09.gif');return true" onmouseout="changeImages( /*CMP*/'normal_09',/*URL*/'bilder/normal_09.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=schule"><IMG SRC="bilder/normal_09.gif" name="normal_09" WIDTH=52 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_10',/*URL*/'bilder/over_10.gif');return true" onmouseout="changeImages( /*CMP*/'normal_10',/*URL*/'bilder/normal_10.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=stuff"><IMG SRC="bilder/normal_10.gif" name="normal_10" WIDTH=46 HEIGHT=23 ALT="" border="0"></a></TD>
								<TD><a onmouseover="changeImages( /*CMP*/'normal_11',/*URL*/'bilder/over_11.gif');return true" onmouseout="changeImages( /*CMP*/'normal_11',/*URL*/'bilder/normal_11.gif');return true" href="http://www.demoehn.de/homepage/index.php?link=gaestebuch"><IMG SRC="bilder/normal_11.gif" name="normal_11" WIDTH=73 HEIGHT=23 ALT="" border="0"></a></TD>
							</TR>
						</TABLE>
					</td>
				</tr>
				<tr height="10">
					<td height="10"><spacer size="10" type="vertical"></td>
				</tr>
				<tr>
					<td>
						<div align="center">
						<?php
include ($link.".php");
?>
							</div>
					</td>
				</tr>
				<tr height="10">
					<td align="center" height="10"><spacer size="10" type="vertical"></td>
				</tr>
				<tr>
					<td align="center"><object classid="clsid:-)27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="60" width="468">
							<param name="movie" value="noelle_fullsize.swf">
							<param name="quality" value="best">
							<param name="play" value="true">
							<embed height="60" pluginspage="http://www.macromedia.com/go/getflashplayer" src="noelle_fullsize.swf" type="application/x-shockwave-flash" width="468" quality="best" play="true"> 
						</object></td>
				</tr>
			</table>
		</form>

</body>

</html>

und dann so
PHP:
<?php
echo '<form action="newComment.php?senden=1" method="post" name="entryComment">';
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><font size="1" face="Verdana,Helvetica,Arial,Geneva">Name:</font></td>';
echo '<td><input type="text" name="name" size="24"></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td><textarea name="text" rows="8" cols="55"></textarea></td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo '</td>';
echo '<td align="right"><input type="submit" name="senden" value="senden"></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
include ("newssystem/config.inc.php");
if(isset($senden) or isset $_GET[senden]) {
$id = 1;
$datum = time();
$dataBase = "DB87590";
$connectIt = mysql_connect($dbserver,$nutzer,$passwort);
mysql_select_db($dataBase);
$insertIn = "INSERT INTO comments (name, text, zeit, newsId) VALUES ('$name', '$text', '$datum', '$id');";
$results = mysql_query($insertIn, $connectIt);
if(isset($results) or isset($_GET[results]) or isset($_POST[results])) {
echo "oki";
}
}
?>



PS falls er es immer noch nicht will machst in das Formular ein verstecktes Feld
<form action="newComment.php" method="post" name="entryComment">
<input type="hidden" name="senden" value="1">

und prüfst dann aber

if (isset($_POST[senden])){
 
Zuletzt bearbeitet von einem Moderator:
Zurück