Bonjour,
je débute en php, et je suis en train d'essayer de crée un formulaire où on inscrit son mail pour recevoir une newsletter.
Le problème est que lorsque j'essaye de rentrer une adresse email sur la page html, la page php s'ouvre en mettant les erreurs:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '****.sql.free.fr' (1) in /mnt/167/sdb/d/3/****/cible.php on line 12
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /mnt/167/sdb/d/3/****/cible.php on line 13
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /mnt/167/sdb/d/3/****/cible.php on line 17
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /mnt/167/sdb/d/3/****/cible.php on line 20
Unknown MySQL server host '****.sql.free.fr' (1)
------
voici ma page html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans nom</title> </head> <body> <p>Pour vous inscrire à la newsletter, tapez votre email:</p> <p> </p> <form method="post" action="cible.php" enctype="multipart/form-data"> Votre email : <input type="text" name="email" size="20"> <input type="submit" value="OK"> </form> </body> </html>
----
et voici ma page php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans titre</title> </head> <body> <?php mysql_connect("localhost", "****", "******"); mysql_select_db("test"); if (isset($_POST['email'])) { $email = mysql_real_escape_string(htmlspecialchars($_POST['email'])); // On utilise mysql_real_escape_string et htmlspecialchars par mesure de sécurité // On peut enfin enregistrer ) mysql_query("INSERT INTO formulaire VALUES('', '" . $email . "')") or die (mysql_error()); } $email = $_POST['email']; $point = strpos($email,"."); $aroba = strpos($email,"@"); if($point=='') { echo "Votre email doit comporter un <b>point</b>"; } elseif($aroba=='') { echo "Votre email doit comporter un <b>'@'</b>"; } else { echo "Merci vous êtes bien inscrit à la newsletter des elans d'arkel. Vous recevrez des infos par email. Votre email est: '<a href=\"mailto:"."$email"."\"><b>$email</b></a>'"; } mysql_close(); ?> </body> </html>
voilà, j'espère que vous pourrez m'aider à voir plus clair dans ce problème..
merci d'avance!