Jump to content

jilana2

Members
  • Posts

    4
  • Joined

  • Last visited

jilana2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okey I need the success and fail messages as well. Could you help I'm new to php and the form thing. If you could use my code and change it so that I can paste it in my documents you would be an angel. I need this to work soon :/
  2. How do I make the echo show when clicking submit and disappear when the user corrects it?
  3. Okej. I managed to solve the "success message" thing a day ago with the code below. Now how do I do the validation & php part. The user can disable javascript in there browser so I want things to be server sided to prevent spam. <script> $(function() { $('#contactus').submit(function (event) { event.preventDefault(); event.returnValue = false; $.ajax({ type: 'POST', url: 'php/mail.php', data: $('#contactus').serialize(), success: function(res) { if (res == 'successful') { $('#status').html('Det uppstod ett fel!').slideDown(); } else { $('#status').html('Tack! Ditt meddelande har skickat.').slideDown(); document.getElementById("contactus").reset(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('#status').html('Det uppstod ett fel!').slideDown(); } }); }); }); </script>
  4. Hi! I need help! No other forum is helping me and it's a bit urgent. I have searched all over the internet and tried over 30 different codes but I can't get this to work. Im very new to php and that probably why. What I want help with: 1. I want my form to be validated server side. When the name or message field is left empty a errormessage(please fill in name, please fill in message) should be shown above the form on the SAME page without reloading or redirecting. 2. Check so that the email entered in the email field is a valid email and not just filled out. 3. If everything is filled out correctly the form should be sent and a message is displayed above the form just like the error-messages for the fields. Php: <?php $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $recipient = "info@mydomain.com"; $subject = "Via Webbkontakt"; $formcontent = "Namn: $name <br/> Email: $email <br/> Telefon: $phone <br/><br/> Meddelande:<br/><br/> $message"; $headers = "From: " ."MyDomain<info@mydomain.com>" . "\r\n"; $headers .= "Reply-To: ". "$email" . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; if(@mail($recipient, $subject, $formcontent, $headers)) { echo "successful"; } else { echo "error"; } ?> Html: <form class="form" id="contactus" action="php/mail.php" method="post" accept-charset="UTF-8"> <label for="nametag">Namn<FONT COLOR="#FF0060">*</FONT></label> <input name="name" value="" type="text" id="name"> <label for="emailtag">Email<FONT COLOR="#FF0060">*</FONT></label> <input name="email" value="" type="text" id="email"> <label for="phonetag">Telefon</label> <input name="phone" type="text" id="phone" value="" /> <label for="messagetag">Meddelande<FONT COLOR="#FF0060">*</FONT></label> <textarea name="message" id="message" value="" style="width: 87%; height: 200px;"></textarea> <label class="placeholder"> </label> <button class="submit" name="submit">Skicka</button> </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.