Jump to content

session_start()


lamurio

Recommended Posts

hello, i don't understand this script:

 

<?php

session_start();

if(isset($_SESSION['captcha_spam']) AND $_POST["sicherheitscode"] == $_SESSION['captcha_spam']){

unset($_SESSION['captcha_spam']);

 

//

//

//orginal script

//

//

 

 

}else{

  die ("Der Sicherheitscode ist falsch!");

}

 

how must it insert?

 

gaestebuch.php

<html>
<head>
<title>Mein Gästebuch</title>
</head>
<body>
<h2>Mein Gästebuch</h2>
<a href="#neuereintrag">Eintrag hinzufügen</a><br><br>
<?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>Eintragen 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>
<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>
</body>
</html>

 

or

 

eintrag-einfuegen.php

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <meta http-equiv="expires" content="0"/>
  <title>Affenformular</title>
</head>
<body>
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');

if (isset($_POST['Send'])) {

    $eingabe = array(); // zum abspeichern überprüfter Benutzereingaben
    $error   = array(); // zum merken von fehlerhaften Benutzereingaben

    /*
     * Überprüfung eines Textfeldes: Wurde auch ein Name eingegeben?
    */
    if (isset($_POST['Name']) && strlen(trim($_POST['Name'])) && !is_array($_POST['Name'])) {
        $eingabe['Name'] = htmlspecialchars(trim($_POST['Name']));
    } else {
        $error['Name'] = true;
    }
    if (isset($_POST['Email']) && strlen(trim($_POST['Email'])) && !is_array($_POST['Email'])) {
        $eingabe['Email'] = htmlspecialchars(trim($_POST['Email']));
    } else {
        $error['Email'] = true;
    }
    if (isset($_POST['Eintrag']) && strlen(trim($_POST['Eintrag'])) && !is_array($_POST['Eintrag'])) {
        $eingabe['Eintrag'] = htmlspecialchars(trim($_POST['Eintrag']));
    } else {
        $error['Eintrag'] = true;
    }
if (empty($error)) {
$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);
mysql_affected_rows($DatabasePointer) == 1;

echo '<p>Vielen Dank für Ihren Eintrag!<br>';
echo '<a href="?open=gaestebuch">Zurück</a></p>';
exit();
}
else
{
print_r($error);
echo '<p>Beim Eintragen ist ein Fehler aufgetreten.<br>';
echo '<a href="javascript:history.back();">Zurück</a></p>';
}}
?>
</body>
</html>

 

or

 

index.php

 

<?php session_start() ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
</html>


<?php

# --- > Switchseiten

switch( $_GET['open'] )
{
    case home:
    $content = "home.php";
    break;
    case shop:
    $content = "shop.php";
    break;
    case diabetiker:
    $content = "diabetiker.php";
    break;
    case logostruempfe:
    $content = "logostruempfe.php";
    break;
    case versand:
    $content = "versand.php";
    break;
    case veranstaltungen:
    $content = "veranstaltungen.php";
    break;
    case gaestebuch:
    $content = "gaestebuch/gaestebuch.php";
    break;
    case eintrag-einfuegen:
    $content = "gaestebuch/eintrag-einfuegen.php";
    break;
    case eintrag:
    $content = "gaestebuch/eintrag.php";
    break;
    case termine:
    $content = "termine.php";
    break;
    case modellflug:
    $content = "modellflug.php";
    break;
    case links:
    $content = "links.php";
    break;
    case partner:
    $content = "partner.php";
    break;
    case agbs:
    $content = "agbs.php";
    break;
    case impressum:
    $content = "impressum.php";
    break;
    default:
    $content = "home.php";
    break;
}



# ---> Banner
echo '<table border="0" align="center" width="486" height="60">';
echo '	<tr>';
echo '	 <td><img src="layout/banner2.jpg"></td>';
echo '	</tr>';
echo '</table>';


# ---> Linke Seite

echo '<table border="0" align="left" width="70" height="200">';
echo '	<tr>';
echo '	  <td><table border="0" align="left" width="60" height="80">';
echo '		  	<tr>';
echo '	         <td></td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=home">Home</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=shop">Shop</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=diabetiker">Diabetiker</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=logostruempfe">Logostrümpfe</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=gaestebuch">Gästebuch</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=versand">Versand</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=veranstaltungen">Veranstaltungen</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=termine">Termine</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=modellflug">Modellflug</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=links">Links</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=partner">Partner</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=agbs">AGBs</td></tr>';
echo '				<tr><td style="background: url(layout/buttonblank.jpg) no-repeat;
        height:25px; padding-left:10px; padding-right:10px;"><a href="?open=impressum">Impressum</td></tr>';
echo '			 </td>';
echo '		  	</tr>';
echo '		  </table></td>';
echo '	</tr>';
echo '<td><table border="1" rules=all align="left" width="60" height="80">';
echo '		  	<tr>';
echo '			 <td><img src="layout/news.gif" width="125" height="77"></td></tr>';
echo '		  </table></td>';
echo '</table>';


# ---> Haupseite

echo '<table border="0" width="800" height="520">';
echo '	<tr>';
echo '   <td valign="top" align="justify">';
include($content);
echo '   </td>';
echo '	</tr>';
echo '</table>';


# ---> Copyright

echo '<p class="copyright">copyright</p>';
?>

 

Link to comment
https://forums.phpfreaks.com/topic/148455-session_start/
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.