Page 1 sur 1

Livre d'Or

Posté : 25 oct. 2005, 09:36
par Photographiquement Vôtre
J'ai repris un livre d'or sur un site.

Je n'arrive pas à envoyer un message sur local host.

Est ce du à un Problème sur $page =
$_SERVER ["PHP_SELF"]; 
???

Message :

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-7\www\haute-definition\livredor.php on line 71

Voici le détail de connection.php

Merci d'avance

Posté : 25 oct. 2005, 09:38
par pjl
c'est marqué dans le message d'erreur.

Il n'arrive pas à envoyer un mail en utilisant la fonction mail() et le problème se situe ligne 71.

Livre d'Or

Posté : 25 oct. 2005, 10:09
par Photographiquement Vôtre
Cela ne m'aide pas beaucoup mais je m'aperçois que je n'ai pas joint mon programme ainsi que Connection.php:
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Livre d'Or</title>

  <style type="text/css">
   body{
   background-color: bisque;
   text-align:center
   }
   table{
   background-color: burlywood;
   }
   td.gauche{text-align:left}
   td.droite{text-align:right}
  </style>
 </head>

<body>

<table
 style="padding: 0px; width: 90%; margin-left: auto; margin-right: auto; color: rgb(102 0, 0);"
 border="0" cellpadding="2" cellspacing="2">
   <tr>
      <td
 style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
 href="index.php" style="text-decoration: none;font-size: 20px;">Accueil</a></td>
  <td
       style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
 href="Themes.php" style="text-decoration: none;font-size: 20px;">Galerie</a></td>  
 <td
 style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
 href="Auteur.php" style="text-decoration: none;font-size: 20px;">Auteur</a></td>
 <td
  style="width: auto; text-align: center; color: rgb(102, 0, 0);font-size: 20px;"><a
 href="liens.php" style="text-decoration: none;">Liens</a></td>     
  </table>

 <br><br><br><br>

<?php
//ATTENTION SUR LIVRE = connexion
include("connection.php");

//Initialisation des variables
$table="tbllivredor";
$page = $_SERVER ["PHP_SELF"];
$adresseemail="[email protected]";
$name="";
$city="";
$country="";
$email="";
$url="";
$note="";
$comment="";

if (isset($_POST["txtName"])) $name=htmlspecialchars(stripslashes($_POST["txtName"]), ENT_QUOTES);
if (isset($_POST["txtCity"])) $city=htmlspecialchars(stripslashes($_POST["txtCity"]), ENT_QUOTES);
if (isset($_POST["lstCountry"])) $country=htmlspecialchars(stripslashes($_POST["lstCountry"]), ENT_QUOTES);
if (isset($_POST["txtEmail"])) $email=htmlspecialchars(stripslashes($_POST["txtEmail"]), ENT_QUOTES);
if (isset($_POST["txtUrl"])) $url=htmlspecialchars(stripslashes($_POST["txtUrl"]), ENT_QUOTES);
if (isset($_POST["txaComment"])) $comment=htmlspecialchars(stripslashes($_POST["txaComment"]), ENT_QUOTES);?>

  <?php
   // Si le bouton Submit a été enfoncé et que Nom et Commentaire ne sont pas vides
   if (!empty($comment) && !empty($name)) {
    $date = date("d/m/y"); // 
//
    
    //Sinon, envoi d'un mail au webmaster
    mail($adresseemail,"Nouveau message dans le livre d'OR",$date."\nNom :".$name."\nVille :".$city."\nPays :".$country."\nMail :".$email."\nSite :".$url."\nNote :".$note."\nTexte :".$comment);
   
  ?>
<!-- -->
  <p id="rep">Merci d'avoir signé le livre d'or</p>
  <p>
  Le message sera rajouté dès que possible
  </p>
  <p>
  <a href="<?= $page ?>">--  Retourner sur le livre d'or --</a>
  </p>
<!-- -->
  <?php
   } 
   else{ 
  ?> 
<!-- -->
  <h1>Bienvenue sur mon livre d'or</h1>
  <p>&nbsp;</p>
  <?php
   $result = mysql_query("SELECT * FROM $table ORDER BY id_message DESC");
   $total=mysql_numrows($result);
  
  ?>
<!-- -->
  <table border="1" width="50%" cellspacing="0" cellpadding="5">
   <tr>
    <td class="gauche">[<a href="#form">Signer le Livre d'Or</a>]</td>
    
   </tr>
  </table>
<!-- -->
  <?php while ($val = mysql_fetch_array($result)) { ?>
  <p>&nbsp;</p>
  <table border="0" width="50%" cellspacing="0">
   <tr>
    <td colspan="2" class="gauche"><b>De : </b><?= $val["nom"]; ?>
     <?php if ($val["email"]) { ?>&nbsp;&nbsp;&nbsp;<A href="mailto:<?= $val["email"]; ?>"><small>[Écrivez moi] </small></A><?php } ?>
     <?php if ($val["site"]!="http://") { ?><A href="<?= $val["site"]; ?>"><small>[Site Web] </small></A><?php } ?>
    </td>
   </tr>
   <tr>
    <td class="gauche"><?php if($val["ville"]){echo "<b>Ville : </b>".$val['ville']." "; } ?></td>
    <td class="droite"><?php if($val["pays"]){echo "<b>Pays : </b>".$val['pays']."<br>"; } ?></td>
   </tr> 
   <tr>
    <td colspan="2"><b>Inscrit le : </b> <?= $val["date"]; ?></td>
   </tr>
   <tr>
    <td colspan="2"><hr><b>Message : </b><?= str_replace("<","<",$val["commentaire"]); ?></td>
   </tr>
  </table> 
  <?php 
  } 
  ?>
<!-- -->
  <p><a name="form"></a>&nbsp;</p>
  <!--Création du formulaire-->      
  <form method="post" action="<?= $page ?>">
   <fieldset><legend>Laissez nous votre commentaire</legend>
    <div style="text-align:center">
     <table cellpadding="3">
      <tr>
       <td colspan="4">Nom <input name="txtName" value="" size="15" maxlength="30"></td>
       <td colspan="4">Ville <input name="txtCity" size="15" maxlength="30"></td>
       <td colspan="4">Pays <select name="lstCountry">
       <option value="France" selected>France
       <option value="Canada">Canada
       <option value="Belgique" >Belgique
       <option value="Suisse">Suisse
       <option value="Luxembourg">Luxembourg
       <option value="Autre">Autre
       </select>
       </td>
      </tr>
      <tr>
       <td>&nbsp;</td>
       <td colspan="5">E-mail<br><input name="txtEmail" size="20" maxlength="30"></td>
       <td colspan="5">Site<br><input name="txtUrl" value="http://" size="20" maxlength="30">
       </td>
       <td>&nbsp;</td>
      </tr>
      
      <tr>
       <td colspan="12"><br><textarea name="txaComment" rows="10" cols="55"></textarea>
       <br><br><input type="submit" value="Signer le livre" name="bntSoumet"><input type="reset" value="Effacer"><br>
       </td>
      </tr>
     </table>
    </div>
   </fieldset>
  </form>

  <?php
  }
  ?> 
 </BODY>
</HTML>
Programme : Connection.php
<?php

    $server="localhost"; 	// mysql server address
    $dbname="bdphotos"; 	// mysql database name
    $uid="root"; 		// username for that database
    $pwd=""; 		// password for that database
    $db = mysql_connect($server, $uid, $pwd);
    
    mysql_select_db($dbname,$db)or die ("Connexion à la base impossible");


?>

Posté : 25 oct. 2005, 10:14
par TheMeche
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-7\www\haute-definition\livredor.php on line 71
Il est marqué que le probléme viens de SMTP et co.
Hors en local l'envoye de mail est pas possible sans modifier le php.ini

cherche un truc du genre:

Code : Tout sélectionner

[mail function] ; For Win32 only. paramètre du serveur smtp de votre fournisseur d'accès SMTP = smtp.free.fr ;for win32 only ; For Win32 only. l'adresse e-mail qui apparaitra dans le message envoyé sendmail_from = [email protected] ;for win32 only ; For Unix only. à configurer seulement si utilisé unix ou linux ;sendmail_path = [email protected] ;

Posté : 25 oct. 2005, 10:24
par charabia
Comme le dit les autres, ton problème se situe au niveau de la fonction mail().
//Sinon, envoi d'un mail au webmaster 
    mail($adresseemail,"Nouveau message dans le livre d'OR",$date."\nNom :".$name."\nVille :".$city."\nPays :".$country."\nMail :".$email."\nSite :".$url."\nNote :".$note."\nTexte :".$comment);
Si c'est juste cette ligne qui pose soucis, je pense que tu peux l'enlever juste pour faire des tests en local. Il s'agit juste d'un mail pour te prévenir qu'il y a un nouveau message dans ton livre d'or.

Une fois mis sur ton hébergeur ça fonctionnera normalement.

Livre d'Or

Posté : 25 oct. 2005, 10:34
par Photographiquement Vôtre
J'ai enlevé la ligne mais j'ai maintenant ce message :

Forbidden
You don't have permission to access /Haute-Definition/<br /><b>Notice</b>: Undefined variable: page in <b>c:/program files/easyphp1-7/www/haute-definition/livredor.php</b> on line <b>129</b><br /> on this server.


--------------------------------------------------------------------------------

Apache/1.3.27 Server at 127.0.0.1 Port 80

Cela revient à ma première question : QUID de cette ligne

$page = $_SERVER ["PHP_SELF"];

Posté : 25 oct. 2005, 11:02
par charabia
Si tu fais un echo sur :
echo $_SERVER ["PHP_SELF"];
tu as quoi ?

Posté : 25 oct. 2005, 11:08
par pjl
c'est ca la ligne 129 : $page = $_SERVER ["PHP_SELF"]; ?


et regarde donc cette page : http://www.phptools4u.com/articles/view.php?article=1