Nic727 Posted November 20, 2014 Share Posted November 20, 2014 Hi, I would like to have help, because I'm trying to create a contact form and was following this tutorial, but now I'm lost with php... That's what I have : First of all, my submit button is weird. I'm supposed to have a text inside, but it's only show the blue background. It's supposed to be like that : http://image.noelshack.com/fichiers/2014/47/1416511250-envoyer.gif but smaller My goal is to have something like that : That's my HTML5 and my CSS3 : <form method="post" action="index.html"> <P>Les champs sont obligatoires*</p> <label>Prénom*</label> <input name="prenom" type="text"> <label>Nom</label> <input name="nom" type="text"> <label>Email*</label> <input name="email" type="email"> <label>Pays</label> <input name="pays" type="text"> <label>Sujet*</label> <input name="sujet" type="text"> <label>Votre message*</label> <textarea name="message"></textarea> <input id="submit" name="submit" type="submit" value="envoyer"> </form><?php $premon = $_POST['prenom']; $nom = $_POST['nom']; $email = $_POST['email']; $pays = $_POST['pays']; $message = $_POST['message']; $from = 'From: TangledDemo'; $to = 'contact@nicolas-duclos.com'; $subject = 'Hello'; $human = $_POST['human']; $body = "From: $namen E-Mail: $emailn Message:n $message"; if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; }?> nput, textarea { width:439px; height:27px; background:#F7F7F7; border:1px solid #dedede; padding:10px; margin-top:3px; font-size:0.9em; color:#3a3a3a; font-style: italic; border-radius:2px;}textarea { height:213px; resize:none;}input:focus, textarea:focus { border:1px solid blue;}#submit { width:127px; height:38px; background:url(../img/envoyer.gif); text-indent:-9999px; border:none; margin-top:20px; cursor:pointer;} #submit:hover { opacity:.9; } What I would like to know is how to make that when you click on the submit button, you have a message appearing and the form disappearing? For the moment, when I click on my weird submit button, it's going on the top of the page. In the php, I don't understand what to do with $from = 'From: TangledDemo'; and $subject = 'Hello'; How to make fields required? Thank you for your help Link to comment Share on other sites More sharing options...
Ingolme Posted November 20, 2014 Share Posted November 20, 2014 This means that your file isn't being interpreted as PHP on the server. Does your file have a .php extension? If it does, does your server support PHP? PHP doesn't work on the browser, it needs a server to run it, so you can't test PHP files straight from your filesystem. Link to comment Share on other sites More sharing options...
Nic727 Posted November 22, 2014 Author Share Posted November 22, 2014 ok, but can you help me to understand this : $from = 'From: TangledDemo'; $to = 'contact@nicolas-duclos.com'; $subject = 'Hello'; $human = $_POST['human']; $body = "From: $namen E-Mail: $emailn Message:n $message"; if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; }?> I don't have a php file in my folder, because I don't really know what it suppose to do. I just changed :form method="post" action="index.php">toform method="post" action="index.html"> but I don't know if it's good. If not, I will try to find something easier on the web. I'm learning HTML5 and CSS3, but I don't understand PHP yet. Link to comment Share on other sites More sharing options...
Ingolme Posted November 22, 2014 Share Posted November 22, 2014 You can't manage forms without PHP or a similar server-side programming language, and in most cases PHP files must have a .php extension. I can't help you to understand it until you've begun learning the basics of PHP. If you're still only learning HTML and CSS, forget about forms, you need other languages to use them. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now