Last active
March 31, 2020 16:48
-
-
Save pierrealexaline/8332c5b837ff963d529c9e4625c06f7a to your computer and use it in GitHub Desktop.
WCS - Les formulaires et leur traitement HTML et PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Enoncé : | |
À partir de ce que tu viens de réaliser, | |
il faut améliorer ce formulaire. et afficher un message à réception | |
Objectifs : | |
Le formulaire de contact comporte les champs : | |
nom, | |
prénom, | |
e-mail, | |
téléphone, | |
sujet (sous forme de liste déroulante), | |
message (textarea). | |
Le formulaire renvoie vers une nouvelle page PHP qui affiche le message demandé | |
plus haut contenant les informations issues du formulaire. | |
Le code est disponible sur un dépot Gist ou Github. | |
*/ | |
echo "Merci " . $_POST['user_surname'] . " " . $_POST['user_name'] . " de nous avoir contacté à propos de " . $_POST['subject'] . " | |
Un de nos conseiller vous contactera soit à l’adresse " . $_POST['user_mail'] . " | |
ou par téléphone au " . $_POST['user_phone'] . " dans les plus brefs délais pour traiter votre demande : | |
" . $_POST['user_message']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="x-ua-compatible" content="ie=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<title>Page Title</title> | |
<link rel="stylesheet" href="css/styles.css" /> | |
<link rel="icon" href="images/favicons/favicon.ico" /> | |
<style> | |
h1, h2{ | |
text-align:center; | |
} | |
form { | |
margin: 0 auto; | |
width: 400px; | |
padding: 1em; | |
border: 1px solid #CCC; | |
border-radius: 1em; | |
} | |
form div + div { | |
margin-top: 1em; | |
} | |
label { | |
display: inline-block; | |
width: 90px; | |
text-align: right; | |
} | |
input, textarea { | |
font: 1em sans-serif; | |
width: 300px; | |
box-sizing: border-box; | |
border: 1px solid #999; | |
} | |
input:focus, textarea:focus { | |
border-color: #000; | |
} | |
textarea { | |
vertical-align: top; | |
height: 5em; | |
} | |
.button { | |
padding-left: 90px; | |
} | |
button { | |
margin-left: .5em; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Contact</h1> | |
<header></header> | |
<main> | |
<section> | |
<article> | |
<h1>Contact form</h1> | |
<form action="http://localhost:8000/thanks.php" method="post"> | |
<div> | |
<label for="name">Name :</label> | |
<input type="text" id="name" name="user_name"> | |
</div> | |
<div> | |
<label for="name">Surname :</label> | |
<input type="text" id="surname" name="user_surname"> | |
</div> | |
<div> | |
<label for="mail">e-mail :</label> | |
<input type="email" id="mail" name="user_mail"> | |
</div> | |
<div> | |
<label for="phone">Phone :</label> | |
<input type="tel" id="phone" name="user_phone" pattern="+[0-9]{3}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}"> | |
</div> | |
<div> | |
<label for="mail">Subject :</label> | |
<select id="subject" name="subject"> | |
<option value="info">Get informations</option> | |
<option value="help">Tell for help</option> | |
<option value="bug">Declare a bug</option> | |
</select> | |
</div> | |
<div> | |
<label for="msg">Message :</label> | |
<textarea id="msg" name="user_message"></textarea> | |
</div> | |
<div class="button"> | |
<button type="submit">Envoyer le message</button> | |
</div> | |
</form> | |
</article> | |
</section> | |
</main> | |
<aside></aside> | |
<footer></footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment