jiminfo Posted October 9, 2014 Share Posted October 9, 2014 Hi Peeps, I have tried but am trying to get a website up and working and am stumbling with the php side of things. Please help. html <form id="contacts-form" name="contacts-form" action="contact1.php" method="post" > <fieldset> <div class="field"> <label>Your Name:</label> <input type="text" class="input" name="name" id="name"> </div> <div class="field"> <label>Your E-mail:</label> <input type="text" class="input" name="email" id="email"> </div> <div class="field"> <label>Your Website:</label> <input type="text" class="input" name="website" id="website"> </div> <div class="field"> <label>Your Message:</label> <textarea name="textarea" id="textarea" cols="" rows=""></textarea> </div> <div class="alignright"><a href="contact-us.html" onclick="document.getElementById('contacts-form').submit()"><strong>Send Your Message!</strong></a></div> </fieldset> </form> php is.. <?php $name = $_POST ['name']; $website = $_POST ['website']; $email = $_POST ['email']; $message = $_POST ['textarea']; if(!$name || !$website || !$email || !$textarea)<form method='post' action='contact1.php'> Name: <br /><input name='name' type='text' value='$name' /><br /><br /> Company: <br /><input name='website' type='text' value='$website' /><br /><br /> EMail: <br /><input name='email' type='text' value='$email' /><br /><br /> Message:<br /> <textarea name='textarea' cols='55' rows='8'>$textarea</textarea><br /><br /> <input type='submit' value='Send' /></form><p>All fields are required</p>$send_to = "info@cropredyvillage.info"; // change to your emailmail($send_to, "Name: $name: $website" , $textarea, "From: $email");echo "Thank you for your feedback";?> form just resets and does not send a mail. I really hope you can help. J Quote Link to comment https://forums.phpfreaks.com/topic/291534-contact-php-file-for-web/ Share on other sites More sharing options...
ginerjm Posted October 9, 2014 Share Posted October 9, 2014 Do you get the thank you for feedback message? Turn on php error checking - might have an error. What is the anchor tag with the onclick event supposed to do for you that a simple submit button doesn't do? Quote Link to comment https://forums.phpfreaks.com/topic/291534-contact-php-file-for-web/#findComment-1493154 Share on other sites More sharing options...
Frank_b Posted October 9, 2014 Share Posted October 9, 2014 (edited) Do you use a php editor ? You should see at once that you miss a php close tag. or is it because bad copy and paste work to this board? start all over like this: <?php $firstname = ''; $error = NULL; if($_SERVER['REQUEST_METHOD'] == 'POST') { $firstname = $_POST['firstname']; //validation if(strlen($firstname) < 2) $error = 'Please fill in your firstname!'; if(!$error) { // do some actions like sending an email // redirect header('Location thankyou.html'); } } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>My first Form</title> </head> <body> <p><?php echo $error; ?></p> <form action="" method="post"> <input type="text" name="firstname" value="<?php echo $firstname; ?>" /> <button type="submit">Send</button> </form> </body> </html> Edited October 9, 2014 by Frank_b Quote Link to comment https://forums.phpfreaks.com/topic/291534-contact-php-file-for-web/#findComment-1493157 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.