November 11, 200818 yr I have a html page with a form that allows a user to send an email to me. It works, and I get the email when i press the submit-button. But how do I display the original html-page with a <p>Thanks for the mail</p> in the content, instead of a new, blank page like the php-code does. Here`s the current code: <?php $to = "tthorki@gmail.com"; $from = $_POST['avsender']; $subject = $_POST['tema']; $message = $_POST['beskjed']; if (mail($to, $from, $message)) { echo "<p>Thanks for the mail</p>"; } else { echo "<p>Mail wasnt sendt.</p>"; } ?> I want the echoes above to appear on a similar html-page as the form, not on a new blank one wich this generates. Hope someone can help=)
November 11, 200818 yr ok so we need to play about with the server because the html page wont have the php engine available assuming the contact.html page is in the wwwroot/public_html... and your running on linux fist edit the file .htaccess and put this in- edit the names to fit if you have these pages in a folder add this without the slash at the front i.e folder/contact.html folder/contact.php RewriteEngine On RewriteBase / RewriteRule contact.html contact.php then rename your contact.html page to contact.php... now in your browser take allok at the contact.html page... if nothing has changed it worked... so then just add the below code to your contact page and your done <?php if(isset($_POST['beskjed'])){ $to = "tthorki@gmail.com"; $from = $_POST['avsender']; $subject = $_POST['tema']; $message = $_POST['beskjed']; if (mail($to, $from, $message)) { echo "<p>Thanks for the mail</p>"; } else { echo "<p>Mail wasnt sendt.</p>"; } } hope that helps
November 12, 200818 yr forget echo "<p>Thanks for the mail</p>"; and just redirect to a html page that contains "<p>Thanks for the mail</p>" if (mail($to, $from, $message)) { header("Location: ok.html"); } else { header("Location: fail.html"); }
Create an account or sign in to comment