9 pers. connectées au site
Wall posté le Mercredi 9 juillet 2008
code à tester
- <?php
- session_start();
-
- if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
- echo '<div><pre>' ,var_dump($_SESSION),'</pre></div>';
-
-
-
- if (isset($_POST['go']) && $_POST['go']=='Signer') {
- echo '<p>if ligne 10</p>';
- if ((isset($_POST['name'])) && (isset($_POST['email'])) && (isset($_POST['comment']))) {
- echo '<p>if ligne 12</p>';
-
- if ((!empty($_POST['name'])) && (!empty($_POST['email'])) && (!empty($_POST['comment']))) {
- echo '<p>if ligne 14</p>';
-
- $test_mail = eregi ('^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)+$', $_POST['email']);
- if ($test_mail) {
- echo '<p>if ligne 18</p>';
-
-
- $base = mysql_connect ('localhost', 'login', 'pswd');
- $connect_db = mysql_select_db ('my_bdd', $base);
- if ( $connect_db === false) {
- echo '<p>Pas de connection au serveur SQL</p>';
- }
-
-
-
- $sql = 'INSERT INTO livre_or VALUES("", "'.mysql_escape_string($_POST['name']).'", "'.mysql_escape_string($_POST['email']).'", "'.date("Y-m-d H:i:s").'", "'.mysql_escape_string($_POST['comment']).'")';
-
-
- mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error());
-
-
- mysql_close();
-
-
-
-
-
-
-
-
- }
- else {
- $erreur = 'Votre adresse E-mail est invalide.';
- }
- }
- else {
- $erreur = 'Au moins un des champs est vide.';
- }
- }
- else {
- $erreur = 'Les variables nécessaires au script ne sont pas définies.';
- }
- }
-
-
- unset($_SESSION['security_code']);
-
-
- ?>
- <html>
- <head>
- <title>My guestbook</title>
- </head>
- <body>
- <form action="insert_signature.php" method="post">
- <table>
- <tr><td width="97">
- <span class="gras">Name:</span>
- </td><td colspan="2">
- <input type="text" name="name" maxlength="30" size="50" value="<?php if (isset($_POST['name'])) echo htmlentities(trim($_POST['name'])); ?>">
- </td></tr><tr><td>
- <span class="gras">E-mail address:</span>
- </td><td colspan="2">
- <input type="text" name="email" maxlength="50" size="50" value="<?php if (isset($_POST['email'])) echo htmlentities(trim($_POST['email'])); ?>">
- </td></tr><tr><td>
- <span class="gras">Your comment:</span>
- </td><td colspan="2">
- <textarea name="comment" cols="50" rows="10"><?php if (isset($_POST['comment'])) echo htmlentities(trim($_POST['comment'])); ?></textarea>
- </td></tr>
- <tr>
- <td><span class="gras">Security code :</span></td>
- <td width="86"><label>
- <input name="security_code" type="text" tabindex="4" size="5" maxlength="5">
- </label></td>
- <td width="231"><img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td>
- </tr>
- <tr><td><td colspan="2" align="right">
- <input type="submit" name="submit" value="submit">
- </td></tr></table>
- </form>
- <?php
- if (isset($erreur)) echo '<br /><br />',$erreur;
- ?>
- </body>
- </html>
Remonter