Jump to content

Search the Community

Showing results for tags 'contact form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello ! I am sure there is more than one smart freak around here that is awesome enough to figure out the solution for my challenge here. So I have a contact form and events on my website that I promote via other people also (affiliates). People come chose event, put name, email, telefon and promotional CODE (actually affiliate code) aff1, aff2 etc. At this point the form sends out an email to me for each registration. How can I make the form send out an email to the affiliate also when a user inserts his affiliate code in the CODE input box ? So one mail comes to me and automaticly one goes to the affiliate. I think at two different solutions - either with database or not. A. database In my database I have one colum with affiliate codes and next one with their email address. The form searches for a match in database for code entered and if finds a match it send a copy of form submission to the email address associated with the affiliate code it found. B. using IF IF input_affcode = 001 then sendmail to aff1@yahoo.com IF input_affcode = 002 then send mail to aff2@gmail.com etc. Now I don't know how to do that in coding Please help me out. For this moment I am using SIMFATIC forms and I would like to have this small function implemented to the code....otherwise it works very well. This is from main code...my thought is to condition the autoresponder to send depending on the code it finds in the input field. $data_email_sender = new FM_FormDataSender(sfm_readfile("./templ/contactus_email_subj.txt"),sfm_readfile("./templ/contactus_email_body.txt"),"%email_f%"); $data_email_sender->AddToAddr("office@universulsacru.ro"); $formmailobj->addModule($data_email_sender); $autoresp = new FM_AutoResponseSender(sfm_readfile("./templ/LP_inregistrare_resp_subj.txt"),sfm_readfile("./templ/LP_inregistrare_resp_body.txt")); $autoresp->SetToVariables("numeprenume_f","email_f"); $formmailobj->addModule($autoresp); All the best to you! Andrei Stefan
  2. Hi, I'm having a problem ever since I switched hosting servers. My contact page form and other email forms aren't working on the server. This is what suport emailed me: Mar 24 19:59:26 hercules suhosin[30188]: ALERT - mail() - To: headers aren't allowed in the headers parameter. (attacker '99.108.165.151', file > '/home/manilade/public_html/wp-includes/class-phpmailer.php', line 769) Mar 24 20:00:19 hercules suhosin[5929]: ALERT - mail() - To: headers aren't allowed in the headers parameter. (attacker '99.108.165.151', file '/home/manilade/public_html/wp-includes/class-phpmailer.php', line 769) When I deleted 769, I got 2 errors. 1. Undefined variable line 771: $isSent = ($rt == 1) ? 1 : 0; 2. Undefined variable line 778: if(!$rt) { Does anyone know how to fix this? thanks.
  3. Hi there, After battling this problem for hours I have bitten the bullet and am asking for HELP! My contact form is not working, it was working, then wasn't...then was and now its definately not! The thankyou page is appearing when I have filled in the details and click SUBMIT- I am just not receiving the email. Here is my form HTML coding (I have highlighted the code that I think is making the form work and not work- as explained below! (file name contactus.html) <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Contact Us</title> <link href="layout.css" rel="stylesheet" type="text/css"> <link href="slider.css" rel="stylesheet" type="text/css"> <link href="fonts.css" rel="stylesheet" type="text/css"> <link href="fonts/sourcecode/stylesheet.css" rel="stylesheet" type="text/css"> <link href="fonts/umbrage/stylesheet.css" rel="stylesheet" type="text/css"> <link href="fonts/maidenorange/stylesheet.css" rel="stylesheet" type="text/css"> <link href="fonts/helvetica/stylesheet.css" rel="stylesheet" type="text/css"> <!--Internet Explorer Script start--> <script> function check(input) { if (input.value != document.getElementById('email_addr').value) { input.setCustomValidity('The two email addresses must match.'); } else { // input is valid -- reset the error message input.setCustomValidity(''); } } </script> <script> document.createElement("article"); document.createElement("footer"); document.createElement("header"); document.createElement("section"); document.createElement("nav"); </script> <!--Internet Explorer Script end--> <script type="text/javascript" src="js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="js/jquery.scrollTo.js"></script> <script> $(document).ready(function() { $('a.panel').click(function () { $('a.panel').removeClass('selected'); $(this).addClass('selected'); current = $(this); $('#wrapper').scrollTo($(this).attr('href'), 800); return false; }); $(window).resize(function () { resizePanel(); }); }); function resizePanel() { width = $(window).width(); height = $(window).height(); mask_width = width * $('.item').length; $('#debug').html(width + ' ' + height + ' ' + mask_width); $('#wrapper, .item').css({width: width, height: height}); $('#mask').css({width: mask_width, height: height}); $('#wrapper').scrollTo($('a.selected').attr('href'), 0); } </script> <style type="text/css"> body section { color: #000; } body section p { color: #000; text-align: center; } #outersection article form table { font-size: 18px; } </style> </head> <body> <!--start navigation--> <nav> <ul> <li><a href="index.html">home</a> </li> <li><a href="aboutus.html">about us</a></li> <li><a href="products.html">products</a> </li> <li><a href="demos.html">demos</a></li> <li><a href="contactus.html">contact us</a> </ul> </nav> <!--end navigation--> <!--start header--> <section> <header> <h1>Order online here</h1> </header> </section> <section id ="outersection"> <article> <form name="html_form_send" method="post" action="thankyou.html"> <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Products Requested*</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"></td> </tr> </table> </form> </article> </section> <section> <p>Have any further queries or questions we can assist you with? Email us <a href="mailto:sales@xxxxxxx">HERE</a></p> </section> <!-- start small section--> <article id= "information"> <h1> Thankyou for visiting us at Autolecs.com.au</h1> </article> <!--end small section--> <!-- start footer--> <footer> <p></p> </footer> <!--end footer--> </body> </html> AND my php coding; (file name send_form_email.php) <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "sales@xxxxxxxxxx"; $email_subject = "Order Received"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <title>contactform</title> <h1>Thank you for your order - one of our friendly sales team will confirm your order soon</h1> Plus I have a confirmation page (file named thankyou.html) <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>THANKYOU!</title> <link href="layout.css" rel="stylesheet" type="text/css"> <link href="fonts.css" rel="stylesheet" type="text/css"> <link href="fonts/sourcecode/stylesheet.css" rel="stylesheet" type="text/css"> <link href="fonts/umbrage/stylesheet.css" rel="stylesheet" type="text/css"> <link href="fonts/maidenorange/stylesheet.css" rel="stylesheet" type="text/css"> <!--Internet Explorer Script start--> <script> document.createElement("article"); document.createElement("footer"); document.createElement("header"); document.createElement("section"); document.createElement("nav"); </script> <!--Internet Explorer Script end--> <style type="text/css"> #outersection #information h1 { color: #FF0; } </style> </head> <body> <!--start navigation--> <nav> <ul> <li><a href="index.html">home</a> </li> <li><a href="aboutus.html">about us</a></li> <li><a href="products.html">products</a> </li> <li><a href="demos.html">demos</a></li> <li><a href="contactus.html">contact us</a> </li></ul> </nav> <!--end navigation--> <!--start header--> <!--end header--> <!--start main section--> <!--end main section--> <!-- start small section--> <section id ="outersection"> <article id= "information"> <h1> </h1> <h1> </h1> <h1> </h1> <h1> </h1> <h1> </h1> <h1>Thankyou - your order has been received and</h1> <h1>you will be contacted shortly by one of our </h1> <h1>friendly sales team!</h1> </article> </section> <!--end small section--> <!-- start footer--> <footer> <p></p> </footer> <!--end footer--> </body> </html> Now, the problem (I think) lies in the highlighted row of HTML code. When I changed it to this the EMAIL worked, but the thankyou page did not appear- just basic text on a blank screen that when clicked 'back' from you are sent back to the form or if closed, closed the whole browser. When changed back to the orginal the thankyou page appeared but no email... Is there a simple answer to get BOTH actions working?! I would be forever thankful for anyone's assistance, this is my first live site and my client has been very patient so far...but time is ticking! Thanking anyone for any assistance! PS- I am a beginner, this is my first live site- go easy on me!
  4. Please assist me with this form. I want to send the email to me when the client hits the send button on www.themogulwaltononthames.com/contacts.html Where on this script should i place my email so that i can receive the form. Here is the java script im using: //forms ;(function($){ $.fn.forms=function(o){ return this.each(function(){ var th=$(this) ,_=th.data('forms')||{ errorCl:'error', emptyCl:'empty', invalidCl:'invalid', notRequiredCl:'notRequired', successCl:'success', successShow:'4000', mailHandlerURL:'bat/MailHandler.php', ownerEmail:'support@template-help.com', stripHTML:true, smtpMailServer:'localhost', targets:'input,textarea', controls:'a[data-type=reset],a[data-type=submit]', validate:true, rx:{ ".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'}, ".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'}, ".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'}, ".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'}, ".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'}, ".message":{rx:/.{20}/,target:'textarea'} }, preFu:function(){ _.labels.each(function(){ var label=$(this), inp=$(_.targets,this), defVal=inp.val(), trueVal=(function(){ var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html() return defVal==''?defVal:tmp })() trueVal!=defVal &&inp.val(defVal=trueVal||defVal) label.data({defVal:defVal}) inp .bind('focus',function(){ inp.val()==defVal &&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl)) }) .bind('blur',function(){ _.validateFu(label) if(_.isEmpty(label)) inp.val(defVal) ,_.hideErrorFu(label.removeClass(_.invalidCl)) }) .bind('keyup',function(){ label.hasClass(_.invalidCl) &&_.validateFu(label) }) label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide() }) _.success=$('.'+_.successCl,_.form).hide() }, isRequired:function(el){ return !el.hasClass(_.notRequiredCl) }, isValid:function(el){ var ret=true $.each(_.rx,function(k,d){ if(el.is(k)) ret=d.rx.test(el.find(d.target).val()) }) return ret }, isEmpty:function(el){ var tmp return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal') }, validateFu:function(el){ el.each(function(){ var th=$(this) ,req=_.isRequired(th) ,empty=_.isEmpty(th) ,valid=_.isValid(th) if(empty&&req) _.showEmptyFu(th.addClass(_.invalidCl)) else _.hideEmptyFu(th.removeClass(_.invalidCl)) if(!empty) if(valid) _.hideErrorFu(th.removeClass(_.invalidCl)) else _.showErrorFu(th.addClass(_.invalidCl)) }) }, getValFromLabel:function(label){ var val=$('input,textarea',label).val() ,defVal=label.data('defVal') return label.length?val==defVal?'nope':val:'nope' } ,submitFu:function(){ _.validateFu(_.labels) if(!_.form.has('.'+_.invalidCl).length) $.ajax({ type: "POST", url:_.mailHandlerURL, data:{ name:_.getValFromLabel($('.name',_.form)), email:_.getValFromLabel($('.email',_.form)), phone:_.getValFromLabel($('.phone',_.form)), fax:_.getValFromLabel($('.fax',_.form)), state:_.getValFromLabel($('.state',_.form)), message:_.getValFromLabel($('.message',_.form)), owner_email:_.ownerEmail, stripHTML:_.stripHTML }, success: function(){ _.showFu() } }) }, showFu:function(){ _.success.slideDown(function(){ setTimeout(function(){ _.success.slideUp() _.form.trigger('reset') },_.successShow) }) }, controlsFu:function(){ $(_.controls,_.form).each(function(){ var th=$(this) th .bind('click',function(){ _.form.trigger(th.data('type')) return false }) }) }, showErrorFu:function(label){ label.find('.'+_.errorCl).slideDown() }, hideErrorFu:function(label){ label.find('.'+_.errorCl).slideUp() }, showEmptyFu:function(label){ label.find('.'+_.emptyCl).slideDown() _.hideErrorFu(label) }, hideEmptyFu:function(label){ label.find('.'+_.emptyCl).slideUp() }, init:function(){ _.form=_.me _.labels=$('label',_.form) _.preFu() _.controlsFu() _.form .bind('submit',function(){ if(_.validate) _.submitFu() else _.form[0].submit() return false }) .bind('reset',function(){ _.labels.removeClass(_.invalidCl) _.labels.each(function(){ var th=$(this) _.hideErrorFu(th) _.hideEmptyFu(th) }) }) _.form.trigger('reset') } } _.me||_.init(_.me=th.data({forms:_})) typeof o=='object' &&$.extend(_,o) }) } })(jQuery) --------------------------------------------------------------- Im also using a form mail handlers PHP script: ---------------------------------------------------------------------------- <?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'A message from your site visitor ' . $_POST["name"]; $messageBody = ""; if($_POST['name']!='nope'){ $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['email']!='nope'){ $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; }else{ $headers = ''; } if($_POST['state']!='nope'){ $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['phone']!='nope'){ $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['fax']!='nope'){ $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; } if($_POST['message']!='nope'){ $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?>
  5. Hey guys. I've been having some frustrating issues with my php + contact form recently. I'm quite the noob when it comes to php in general and have only really worked with contact stuff in the past. I have my contact form calling a php send mail file in a php folder on my server. No idea why, but im not even getting validation. I click send, to no avail. I have attached the code for your perusal. I appreciate any help in advance!! Thank you. Form: <form id="contact-form" class="fixed" action="javascript:void(0);"> <fieldset> <p id="formstatus"></p> <p> <label for="name">Your name: <span class="required">*</span></label><br /> <input class="text" type="text" id="name" name="name" value="" /> </p> <p> <label for="email">Your Email Address: <span class="required">*</span></label><br /> <input class="text" type="text" id="email" name="email" value="" /> </p> <p> <label for="subject">Subject: <span class="required">*</span></label><br /> <input class="text" type="text" id="subject" name="subject" value="" /> </p> <p> <label for="message">Message: </label><br /> <textarea id="message" name="message" rows="3" cols="25"></textarea> </p> <p> <input type="submit" name="submit" value="Send!" /> </p> </fieldset> </form> PHP file (send.php): I've hidden the send to email address for obvious reasons. <?php /////////// Add your own email below //////////////// define("WEBMASTER_EMAIL", 'blah@blah.com'); error_reporting (E_ALL ^ E_NOTICE); ////////////////////////////////////////////////////// function ValidateEmail($email) { $regex = '/([a-z0-9_.-]+)'. # name '@'. # at '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains '.'. # period '([a-z]+){2,10}/i'; # domain extension if($email == '') return false; else $eregi = preg_replace($regex, '', $email); return empty($eregi) ? true : false; } ////////////////////////////////////////////////////// $post = (!empty($_POST)) ? true : false; if($post) { $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $subject = trim($_POST['subject']); $message = stripslashes($_POST['message']); $error = ''; // Check name if(!$name) $error .= 'Name required! '; // Check email if(!$email) $error .= 'E-mail required! '; if($email && !ValidateEmail($email)) $error .= 'E-mail address is not valid! '; // Check message if(!$message) $error .= "Please enter your message!"; if(!$error) { $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion()); if($mail) echo 'OK'; } else echo '<div class="errormsg">'.$error.'</div>'; } ?> and javascript: // ------------------------------------------------------------------------------------------------------- // Form Validation script - used by the Contact Form script // ------------------------------------------------------------------------------------------------------- function validateMyAjaxInputs() { $.validity.start(); // Validator methods go here: $("#name").require(); $("#email").require().match("email"); $("#subject").require(); // End the validation session: var result = $.validity.end(); return result.valid; } // ------------------------------------------------------------------------------------------------------- // ClearForm // ------------------------------------------------------------------------------------------------------- $.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this.tagName.toLowerCase(); if (tag == 'form') return $(':input',this).clearForm(); if (type == 'text' || type == 'password' || tag == 'textarea') this.value = ''; else if (type == 'checkbox' || type == 'radio') this.checked = false; else if (tag == 'select') this.selectedIndex = -1; }); }; $(document).ready(function(){ ////////////////////////////////////////////////////////////////////////////////////////////////////////////// I would appreciate any help! Thanks
  6. I have a simple php contact form: http://brand32.com/clients/dark_water_media/Dark/contact.html Upon clicking "Send" the message displays "Your message has been sent successfully!" but no email is received. I've changed the email in the code multiple times, but the same result (or lack thereof). Here is the php code: <?php $receiverMail = "seanmcpeak@comcast.net"; /* Your email */ $name = ltrim(rtrim(strip_tags(stripslashes($_POST['name'])))); $email = ltrim(rtrim(strip_tags(stripslashes($_POST['email'])))); $website = ltrim(rtrim(strip_tags(stripslashes($_POST['website'])))); $msg = ltrim(rtrim(strip_tags($_POST['msg']))); $subject = $name ." - ".$website; $ip = getenv("REMOTE_ADDR"); $msgformat = "From: $name ($ip)\nEmail: $email\n\n$msg"; /* MSG format */ // VALIDATION if(empty($name) || empty($email) || empty($website) || empty($msg)) { echo "<div id='status' class='error'>The email was not sent. Please fill all the required fields</div>"; } elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { echo "<div id='status' class='error'>The email was not sent. The email address is invalid</div>"; } else { mail($receiverMail, $subject, $msgformat, "From: $name <$email>"); echo "<div id='status' class='ok'>Your message has been sent successfully!</div"; } ?> Thanks in advance.
  7. Basically I've a Contact Form where a user fills in Name, Email Address and Comments and then there is aSubmit button. If I just hit "Submit" without filling in anything or wrong information, it takes me to this page,send_form_email.php. This page has all the validators in it. I want it to sort of (I say sort of because I still need to check whether they input everything correctly) bypass this page and go to "submitted-contact.php" page (it's going to this page but its not showing the following as specified in the 2) where it displays one of the 2 things: 1) Login Success 2) Try Again! Right now, there's nothing showing. :| send_form_email.php has this at the very top and it calls header location to the page, submitted-contact.php SEND_FORM_EMAIL CODE [/b] [b]<?php session_start(); $_SESSION['error']=true; $_SESSION['error']=false; ?> <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "blah@hotmail.com"; $email_subject = "Your email subject line here"; function died($error) { // your error code can go here echo $error; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died(''); } $first_name = $_POST['first_name']; // required $email_from = $_POST['email']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $sendit= @mail($email_to, $email_subject, $email_message, $headers); if($sendit){ header('Location:submitted-contact.php'); }else{echo "Email failed to send";} } ?> SUBMITTED-CONTACT.PHP CODE <!DOCTYPE html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"><style type="text/css"></style> <title>CKK Internet Marketing</title> <link href="style.css" rel="stylesheet" type="text/css" media="all"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lato"> <link rel="shortcut icon" href="images/favicon.ico" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="js/jquery.sticky.js"></script> <script src="js/jquery.cycle.all.js"></script> <script src="js/jquery.smoothscroll.js"></script> <script> $(document).ready(function(){ $(".navigation").sticky({topSpacing:0}); }); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-27381915-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body class="submitted"> <div class="navigation"> <div class="container"> <a href="#"><img src="images/logo.png"</a> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About Us</a></li> <li><a href="/service">Services</a></li> <li><a href="/blog">Blog</a></li> <li><a href="/index.html#contact">Contact</a></li> </ul> </div> </div> <div id="submitted-content-2"> <div class="content container"> <?php if (!isset($_SESSION['flunk'])){ $myString = "MESSAGE FLUNKED!"; echo $myString; }else (!isset($_SESSION['pass'])){ $myString2 = "MESSAGE PASSED!"; ?> <div class="clear"></div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <div class="container"> </div> </div> </body> </html> The php code in submitted-contact.php, the following code is in the right location but just the wrong syntax? <div id="submitted-content-2"> <div class="content container"> <?php if (!isset($_SESSION['flunk'])){ $myString = "MESSAGE FLUNKED!"; echo $myString; }else (!isset($_SESSION['pass'])){ $myString2 = "MESSAGE PASSED!"; ?> <div class="clear"></div> </div> </div> </div> Basically, I want to commute from send_form_email.php to submitted-contact.php one of the two things: 1) If user inputted everything well on the Contact Page, show them, "You're logged in" 2) If user inputted wrong information or did not fill in everything on the Contact Page, show them, "Try Again" I want that to be shown withing my <div class="content container"> Sorry, I know this was a long post but I really could use a hand on this. I have been trying to figure this out for the past couple of days! :| Thanks guys D3158
  8. Hi there! I have only just started making my first page and have thrown myself in the deep end as it seems. My contact page has turned out quite professional but I keep receiving error messages after 'sent'. Previously from my localhost test server the emails did get sent but I did also receive the error message - now, from my remote server (GoDaddy) it does not get sent at all and the error is still there! I receive the following error: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\hosting\12345678\html\contact-page.php on line 54 this is referring to: // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); It seems as if it tries to contact a 3rd party server but I seriously don't have any idea where I can adjust that in my script :-\ I have searched and adjusted some things but simply cannot find the actual issue...anyone here who can help me please? Thanks x
  9. Hi, I've been using the same contact form for over a year for several websites. I've successfully been able to tweak it to suit my needs for each project. However, I am currently trying to use it again, and the form appears to submit, but the email never shows up. I've tried it with two different emails. I tested the form on a previous site I designed, and it no longer works either. I can't test all the others because I no longer can access those clients' emails, but they are on the same server. I'm more of a designer than programmer & know enough PHP to be "dangerous", aka tweak existing code to make it do what I need. I used a verifier & it told me my php was fine & dandy. I'm not sure where the error lies... Thanks for any insight! This is my form in the HTML page: <form name="contactformlite" method="post" action="lite_process.php" onSubmit="return validate.check(this)" target="_self"> <table class="cflite"> <tr><td><h3>FREE Gas Card Entry Form</h3></td></tr> <tr> <td class="cflite_td"> <label for="Full_Name" class="required"> Full Name<span class="required_star"> * </span></label> <input type="text" name="Full_Name" id="Full_Name" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;"> </td> </tr> <tr> <td valign="top" class="cflite_td"> <label for="Email_Address" class="not-required">Email Address<span class="required_star"> * </span></label> <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;"> </td> </tr> <tr> <td valign="top" class="cflite_td"> <label for="Telephone_Number" class="required">Phone Number<span class="required_star"> * </span></label> <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:72%; display:block; margin-right:0px; float:right;"> </td> </tr> <tr> <td valign="top" class="cflite_checkbox"> <input type="checkbox" name="Prop_Mgr" id="Prop_Mgr" value="y"> <input type="hidden" name="Prop_Mgr" value="n" /> <label for="Prop_Mgr" class="not_required" style="margin:0px;">I am a retail property manager.</label> <br> <input type="checkbox" name="Contact_Request" id="Contact_Request" value="y"> <input type="hidden" name="Contact_Request" value="n" /> <label for="Contact_Request" class="not_required" style="margin:0px;">I would like more information on TWS' services.</label> <br> <input type="checkbox" name="Permission" id="Permission" value="y"> <input type="hidden" name="Contact_Request" value="n" /> <label for="Permission" class="required" style="margin:0px;"><span class="required_star"> * </span>I am a new facebook fan of TWS as of 2/25/14. I understand that this entry also signs me up for the monthly email newsletter, which I can unsubscribe from at any time. I agree to be contacted by TWS with the phone number or email address provided here.</label> </td> </tr> <tr> <td class="allfields"><span class="required_star"> * </span>Required for Entry.</td></tr> <tr> <td class="cflite_bottom"> <input type="submit" value="Enter Me Now!" id=submit></td> </tr> </table> </form> This is my first php file: <?php if(isset($_POST['Email_Address'])) { include 'lite_settings.php'; if($email_to == "youremailaddress@yourdomain.com") { die("This message is for the Webmaster. Please enter your email address into the file 'lite_settings.php'"); } function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please close this window and fix these errors.<br /><br />"; die(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Telephone_Number']) || !isset($_POST['Prop_Mgr']) || !isset($_POST['Contact_Request']) || !isset($_POST['Permission'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $telephone = $_POST['Telephone_Number']; // required $prop_mgr = $_POST['Prop_Mgr']; // not required $contact_request = $_POST['Contact_Request']; // required $permission = $_POST['Permission']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The email address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your name does not appear to be valid.<br />'; } if(strlen($telephone) < 12) { $error_message .= 'Your phone number does not appear to be valid. Use format 000-000-0000<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Telephone: ".clean_string($telephone)."\r\n"; $email_message .= "Prop_Mgr: ".clean_string($prop_mgr)."\r\n"; $email_message .= "Contact_Request: ".clean_string($contact_request)."\r\n"; $email_message .= "Permission: ".clean_string($permission)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <? } ?> And the second "settings" file (I put in a fake email & site here, for privacy purposes): <?php $email_to = "fakename@email.com"; // your email address $email_subject = "Facebook Gas Contest Entry"; // email subject line $thankyou = "http://fakesite.com"; // thank you page ?> Lastly, here is my javascript: function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;} return true;} function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;} return true;} function $$(id){if(!has_id(id)&&!has_name(id)){alert("Field "+id+" does not exist!\n Form validation configuration error.");return false;} if(has_id(id)){return document.getElementById(id).value;}else{return;}} function $val(id){return document.getElementById(id);} function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,'').replace(/\s+$/,'');} var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Please fix the following errors:\n\n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+' is invalid\n';if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];} tmp=false;}} if(!tmp){alert(error_message);} if(to_focus.length>0){document.getElementById(to_focus).focus();} return tmp;},checkit:function(cvalue,ctype,cform){if(ctype=="NOT_EMPTY"){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^\s+/,'').replace(/\s+$/,'');}else{return s;}}};
×
×
  • 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.