Jump to content

session_start


lamurio

Recommended Posts

hi, i have a problem with a error for session. error code:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\Program Files (x86)\xampp\htdocs\index.php:8) in D:\Program Files (x86)\xampp\htdocs\gaestebuch\gaestebuch.php on line 1

 

but i can't find the error. help me pleace.

 

<?php session_start();
if(isset($_SESSION['captcha_spam']) AND $_POST["sicherheitscode"] == $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']); ?>

<html>
<head>
<title>Mein Gästebuch</title>
</head>
<body>
<h2>Mein Gästebuch</h2>
<a href="#neuereintrag">Eintrag hinzufügen</a><br><br>
<h3><a name="neuereintrag">Neuer Eintrag:</a></h3>
<form action="?open=eintrag-einfuegen" method="post">
<table border="0">
<tr>
  <td><b>Name:</b></td>
  <td><input name="Name" maxlength="50" type="text"></td>
</tr>
<tr>
  <td><b>E-Mail:</b></td>
  <td><input name="Email" maxlength="50" type="text"></td>
</tr>
<tr>
  <td><b>Homepage:</b></td>
  <td><input name="Homepage" maxlength="50" type="text"> <font color=gray>nur wenn vorhanden</font></td>
</tr>
<tr>
  <td><b>Eintrag:</b></td>
  <td><textarea cols="30" name="Eintrag" rows="5"></textarea></td>
</tr>
<tr>
  <td><img src="captcha/captcha.php" border="0" title="Sicherheitscode"></td>
  <td><input type="text" name="sicherheitscode" size="5"></td>
</tr>
<tr>
  <td align="center" colspan="2">
  <input name="Send" type="submit" value="Eintragen">
  <input name="Reset" type="reset" value="Löschen">
  </td>
</tr>
</table>
</form>
<?php
}else{
   die ("Der Sicherheitscode ist falsch!");
}
?>
</body>
</html>

<?php

$DatabasePointer = mysql_connect("localhost", "root", "");
mysql_select_db("gaestebuch", $DatabasePointer);

$ResultPointer = mysql_query("SELECT * FROM gbdb ORDER BY Erstellt DESC", $DatabasePointer);

?>
<table border="0">
<?php

for($i = 0; $i < mysql_num_rows($ResultPointer); $i++)
{
   $Gaestebuch = mysql_fetch_object($ResultPointer);
?>
<tr>
  <td><b>#<?php echo$i+1; ?>: <?php echo$Gaestebuch->Titel; ?></b></td>
</tr>
<tr>
  <td><?php echo nl2br($Gaestebuch->Eintrag); ?></td>
</tr>
<tr>
  <td>Eintrag von <b><?php echo$Gaestebuch->Name; ?></b> am <b><?php echo substr($Gaestebuch->Erstellt, 8, 2); ?>.<?php echo substr($Gaestebuch->Erstellt, 5, 2); ?>.<?php echo substr($Gaestebuch->Erstellt, 0, 4); ?> <?php echo substr($Gaestebuch->Erstellt, 10); ?></b> <?php echo$Gaestebuch->Homepage; ?></td>
</tr>
<tr>
  <td><hr></td>
</tr>
<?php
}
?>
</table><br><br>

Link to comment
https://forums.phpfreaks.com/topic/148060-session_start/
Share on other sites

error code:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\Program Files (x86)\xampp\htdocs\index.php:8) in D:\Program Files (x86)\xampp\htdocs\gaestebuch\eintrag-einfuegen.php on line 2

 

<?php
session_start();
if(isset($_SESSION['captcha_spam']) AND $_POST["sicherheitscode"] == $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']); ?>

<html>
<head>
<title>Eintrag hinzufügen</title>
</head>
<body>
<?php
$DatabasePointer = mysql_connect("localhost", "root", "");
mysql_select_db("gaestebuch", $DatabasePointer);

$SQL = "INSERT INTO gbdb (Name, Email, Homepage, Eintrag, Erstellt) VALUES ('".$_REQUEST['Name']."', '".$_REQUEST['Email']."', '".$_REQUEST['Homepage']."', '".$_REQUEST['Eintrag']."', NOW(''))";
mysql_query($SQL, $DatabasePointer);

}else{
   die ("Der Sicherheitscode ist falsch!");
} 
if(mysql_affected_rows($DatabasePointer) == 1)
{
?>
<p>Vielen Dank für Ihren Eintrag!<br>
<a href="?open=gaestebuch">Zurück</a></p>
<?php
}
else
{
?>
<p>Beim Eintragen ist ein Fehler aufgetreten.<br>
<a href="javascript:history.back();">Zurück</a></p>
<?php
}
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/148060-session_start/#findComment-777130
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.