Jump to content

teanza

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Age
    29?

teanza's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php if (isset($HTTP_REFERER)) { echo "Thank you for contacting XXX! We will be in touch with you very soon. | <a href='$HTTP_REFERER'>Back to XXX site!</a>"; } else { echo "Thank you for contacting XXX! We will be in touch with you very soon. | <a href='javascript:history.back()'>Back to XXX site!</a>"; } $email_to = "info@XXX.com"; $email_subject = "You have a new XXX inquiry!!!"; $fromemail="inquiry@XXX.com"; function died($error) { 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(); } if(!isset($_POST['name']) || !isset($_POST['selection']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['zip']) || !isset($_POST['comment'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $selection = $_POST['selection']; // required $email = $_POST['email']; // required $phone = $_POST['phone']; // not required $zip= $_POST['zip']; // not required $comment = $_POST['comment']; // required $email_message = "Hello, XXX & XXX! See form details below!\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\r\n"; $email_message .= "Email: ".clean_string($email)."\r\n"; $email_message .= "Phone: ".clean_string($phone)."\r\n"; $email_message .= "Zip Code: ".clean_string($zip)."\r\n"; $email_message .= "Interest: ".clean_string($selection)."\r\n"; $email_message .= "Description of Inquiry: ".clean_string($comment)."\r\n"; $headers = 'From: '.$fromemail. "\r\n". 'Reply-To: '.$email. "\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Hello everyone! My greatest apologies for just getting back to this--I had to travel for quite awhile. SO thanks so much for the code that redirects! I at least have a "back" button now! Also, thank you for the steps on what to know/look for--very helpful. The sheet is linked; code not embedded [intentionally]. It submits, BUT the problems I am still having are: I will like the confirmation/thank you message to remain on the same page as the form without the extension being changed to ".php" I have validation error for the email, however none of the fields are showing as my intended "required"; essentially, blank forms are able to be submitted.. Current code pasted. Thank you guys about 1M times, seriously -t
  2. I cannot edit this post, but wanted to state I have defined the "from" from the 2nd bullet request above; sadly, that is all......
  3. I want to know everything!!!!!!!!!!!!!!!

    1. QuickOldCar

      QuickOldCar

      With knowledge comes power, people with power usually get someone else to do it.

    2. Destramic

      Destramic

      women do know it all don't they? :)

  4. Hi everyone! So you can see how often I use PHP, seeing my last post was 2009. My goal: Keep the contact page HTML, hence the linked sheet Have email come from the host, reply to the user Have email and name required only Have submission success on the SAME HTML page So here is what I tried to do, never worked: <?php $to = "XXX@XXX.com"; $subject = "XXX Web Inquiry"; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $selection = $_POST['selection']; $comment = $_POST['comment']; $body .= "Name: " .$POST['name']."\n"; $body .="E-Mail: ".$POST['email']."\n"; $body .="Phone: ".$POST['phone']."\n"; $body .="Selection: ".$POST['selection']."\n"; $body .="Comment: ".$POST['comment']."\n"; $errEmail = $errName = ""; $name = $email = $phone = $selection = $comment = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST['name'])) { $errName = "Name is required"; } else { $name = test_input($_POST["name"]); } if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $errEmail = "Valid email is required"; } else { $email = test_input($_POST['email']); } if (empty($_POST['phone'])) { $phone = ""; } else { $phone = test_input($_POST['phone']); } if (empty($_POST['comment'])) { $comment = ""; } else { $comment = test_input($_POST['comment']); } if (empty($_POST['selection'])) { $selection = ""; } else { $selection = test_input($_POST['selection']); } $msgError = "ERROR: Please re-submit the form; we apologize!"; $msgSuccess = "Sent -- Thank you " . $name . ", we will contact you shortly!"; $header .= 'From: '. $_REQUEST['name']. "\r\n". 'Reply-To: '. $_REQUEST['email'] . "\r\n"; if (isset($_POST['submit'])) { mail($to, $header, $subject, $body, $email); echo $msgSuccess; } else { echo $msgError; } ?> Here is one I stole that I got to somewhat work, as far as just emailing me, but has no restrictions (e.g., would submit empty), didn't always send content, and redirected to the PHP page, so I don't wish to use it; I think I may need to combine the two + add fxn to stay on the same page: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "XXX@XXX.com"; $email_subject = "XXX Website Inquiry"; 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['name']) || !isset($_POST['selection']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['comment'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $selection = $_POST['selection']; // required $email = $_POST['email']; // required $phone = $_POST['phone']; // not required $comment = $_POST['comment']; // required $email_message = "Hello, XXX! See form details below!\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\r\n"; $email_message .= "Email: ".clean_string($email)."\r\n"; $email_message .= "Phone: ".clean_string($phone)."\r\n"; $email_message .= "Selection: ".clean_string($selection)."\r\n"; $email_message .= "Comment(s): ".clean_string($comment)."\r\n"; // create email headers $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> I even tried a blip of Javascript in the HTML form page and added a DIV for the responses to appear on the same page, but all it did was gray the button; nothing else: <script> $("#contact").submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); /* get some values from elements on the page: */ var $form = $( this ), $submit = $form.find( 'input[type="submit"]' ), name_value = $form.find( 'input[name="name"]' ).val(), email_value = $form.find( 'input[name="email"]' ).val(), phone_value = $form.find( 'input[name="phone"]' ).val(), selection_value = $form.find( 'input[name="selection"]' ).val(), comment_value = $form.find( 'textarea[name="comment"]' ).val(), url = $form.attr('action'); /* Send the data using post */ var posting = $.post( url, { name: name_value, email: email_value, phone: phone_value, selection: selection_value, comment: comment_value }); posting.done(function( data ) { /* Put the results in a div */ $( "#contactResponse" ).html(data); /* Change the button text. */ $submit.text('Sent, Thank you'); /* Disable the button. */ $submit.attr("disabled", true); }); }); </script> Finally, the HTML: <div> <form action="contact2.php" method="post" id="contact"> <div class="form-horizontal control-group"> <div class="row"> <div class="span12 leftPad"> <label for="name">Name:</label><input type="text" name="name"> </div> </div><!--row--> <br> <div class="row"> <div class="span12 leftPad"> <label for"email">Email:</label><input type="email" name="email"> </div> </div><!--row--> <br> <div class="row"> <div class="span12 leftPad"> <label for="phone">Phone:</label><input type="tel" name="phone"> </div> </div><!--row--> <br> <div class="row"> <div class="span12 leftPad"> <label for="selection">Area of Interest:</label> <select name="selection"> <option value="General Question">General Question</option> <option value="Inside Sales">Inside Sales</option> <option value="Service">Service</option> <option value="Request a Quote">Request a Quote</option> </select> </div> </div><!--row--> <br> <div class="row"> <div class="span12 leftPad"> <label for="comment">Comments / Application Specifics</label><textarea rows="10" name="comment"></textarea> </div> </div><!--row--> <br> <div class="row"> <div class="span12 leftPad"> <input type="submit" name="submit"> </div> </div><!--row--> <br> <!--<div id="contactResponse"></div>--> <br> </div> <!--form horizontal control group--> </form> </div> I appreciate this very much!!...I assume it's simple for you guys, and I thought I could figure it out. Certainly it isn't impossible to fulfill my simple bulleted list above? I have failed. -t
  5. dude u r SO AWESOME i wanna buy u a murcielago. really, u have helped so much. i feel much better. i know it's prob. no big deal for u guys but i had never used PHP. btw, i had that in the 1st line of my head; not the top of the page so that's why it said it had a header i guess. DUH. ;D ;D ;D ;D ;D ~tina~
  6. hey sorry i bailed there. thanx SO MUCH again. i did that, and made my index a .php. i took the html index out of the file folder. the message is: Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/n/d/andrewsmgt/html/index.php:4) in /home/content/a/n/d/andrewsmgt/html/index.php on line 8 line 8 says 'header'. it also doesn't redirect. n e ideas? T H A N K S!! ~tina~
  7. wow thanx guys! really so nice so my index must be index.php now i suppose? ~tina~
  8. thanx! where do i put that php code? (sorry :'( ) what does changing center w case statement mean? ~tina~
  9. well i just need it 2 go 2 the https:// part. i used a meta tag but it keeps jumping: andrews-management.com i looked-up a php file, but i suppose i failed 2 use it properly! i need the users to never come across the page without the secure 's'. ~tina~
  10. sorry i mean redirect the index page lol. do u think i should for the form? is it bad 2 have it w/that extension? ~tina~
  11. hopefully i can comprehend that wholly in the near future. i appreciate it though! ~tina~
  12. u rock my world. i have very little idea w/what i am doing. i started out doing a nice basic site, lol. it worked. ur awesome! so now that u helped with it, maybe u can tell me how 2 redirect the stupid page? i did it in the meta tag but it keeps jumping back and forth. ~tina~
  13. thanx q695; unfortunately that is beyond me :'( ~tina~
  14. ok i used the code function this time thanx <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contact" id="contact"> <span id="sprytextfield1"> <label> </span><br /> <br /> <div align="right"><span><span class="style20"><span class="style21">F</span>irst name</span> <input type="text" name="firstname" id="firstname" /> </span></div> <span> </label> <span class="textfieldRequiredMsg">Kindly enter your first name </span></span><br /> <br /> <span id="sprytextfield2"> <label> </span> <div align="right"><span class="style20"><span class="style21">L</span>ast name </span> <input type="text" name="lastname" id="lastname" /> </div> <span> </label> <span class="textfieldRequiredMsg">Kindly enter your last name </span></span> <br /> <br /> <span id="sprytextfield3"> <label> </span> <div align="right"><span class="style20"><span class="style21">E</span>mail address</span> <input type="text" name="email" id="email" /> </div> <span> </label> <span class="textfieldRequiredMsg">Kindly enter your email address </span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> <br /> <br /> <span id="sprytextfield4"> <label> </span> <div align="right"><span class="style20"><span class="style21">P</span>hone number</span> <input type="text" name="telephone" id="telephone" /> </div> <span></label><span class="textfieldRequiredMsg">Kindly enter your phone number </span><span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span> <br /> <br /> <span id="spryselect1"> <label> </span> <div align="right"><span class="style20"><span class="style21">C</span>omplex of interest</span> <select name="complexes" id="complexes"> <option value="-1" selected="selected">Please choose one</option> <option value="0">None/General inquiry</option> <option value="1">Seville Square</option> <option value="2">Stonehenge</option> <option value="3">Logan Road</option> </select> </div> <span> </label> <span class="selectInvalidMsg">Kindly select a complex </span><span class="selectRequiredMsg">Kindly select a complex </span></span> <br /> <br /> <span> <label> </label> </span> <label><div align="right"><span class="style11 style22"><span class="style21">A</span>ny additional comments?</span><span> <textarea name="additionalwords" id="additionalwords" cols="45" rows="5"></textarea> </span></div> </label> <span> <span class="textareaRequiredMsg">A value is required.</span></span><br /> <label> <div align="center"> <input type="submit" name="submit" id="submit" value="Submit!" /> </div> </label> </form> ~tina~
  15. the site is here andrews-management.com/contactus.php i am messing w/the rest of the site so try 2 ignore it ~tina~
×
×
  • 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.