Note that there are some explanatory texts on larger screens.

plurals
  1. POphp redirect thank you page
    primarykey
    data
    text
    <p>First I should say I know nothing about php and I'm trying to modify something in my site on my own. I want users to be redirected to a thank you page after they submit the contact form.I have been reading about this subject through all the other answers still I don't get it. </p> <p>My html code is:</p> <pre><code>&lt;div id="form_container"&gt; </code></pre> <p></p> <pre><code>&lt;div id="main"&gt; &lt;p&gt;&lt;small&gt;Name&lt;/small&gt; &lt;input type="text" name="name" id="name" /&gt;&lt;/p&gt; &lt;p&gt;&lt;small&gt;Email&lt;/small&gt; &lt;input type="text" name="email" id="email" /&gt;&lt;/p&gt; &lt;p&gt;&lt;small&gt;Phone&lt;/small&gt; &lt;input type="text" name="phone" id="phone" /&gt;&lt;/p&gt; &lt;p&gt;&lt;small&gt;Message&lt;/small&gt; &lt;textarea name="message" id="message" rows="12"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="submit" name="submit" id="submit" value="Email Us!" /&gt;&lt;/p&gt; &lt;ul id="response" /&gt; &lt;/div&gt;&lt;!--end main --&gt; </code></pre> <p></p> <p>My php code is:</p> <pre><code>&lt;?php $name = trim($_POST['name']); $email = $_POST['email']; $phone = $_POST['phone']; $message = stripslashes($_POST['message'] . "&lt;br&gt;Phone Number: " . $_POST['phone']); $site_owners_email = 'xxxxxxx'; // Replace this with your own email address $site_owners_name = 'xxxxxxxxx'; // replace with your name if (strlen($name) &lt; 2) { $error['name'] = "Your name is....."; } if (!preg_match('/^[a-z0-9&amp;\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) { $error['email'] = "Invalid email address"; } if (strlen($phone) &lt; 10) { $error['phone'] = "Your phone number?"; } if (strlen($message) &lt; 5) { $error['message'] = "Your message?"; } if (!$error) { require_once('phpMailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail-&gt;From = $email; $mail-&gt;FromName = $name; $mail-&gt;Subject = "Website Contact Form"; $mail-&gt;AddAddress($site_owners_email, $site_owners_name); $mail-&gt;AddAddress('xxxxxxxxxx', 'xxxxxxxx'); $mail-&gt;Body = $message $mail-&gt;Send(); echo "&lt;li class='success'&gt; Congratulations, " . $name . ". We received your message&lt;/li&gt;"; } # end if no error else { $response = (isset($error['name'])) ? "&lt;li&gt;" . $error['name'] . "&lt;/li&gt; \n" : null; $response .= (isset($error['email'])) ? "&lt;li&gt;" . $error['email'] . "&lt;/li&gt; \n" : null; $response .= (isset($error['phone'])) ? "&lt;li&gt;" . $error['phone'] . "&lt;/li&gt; \n" : null; $response .= (isset($error['message'])) ? "&lt;li&gt;" . $error['message'] . "&lt;/li&gt;" : null; echo $response; } # end if there was an error sending ?&gt; </code></pre> <p>My js file is</p> <pre><code>$(function() { var paraTag = $('input#submit').parent('p'); $(paraTag).children('input').remove(); $(paraTag).append('&lt;input type="button" name="submit" id="submit" value="Email Us Now!" /&gt;'); $('#main input#submit').click(function() { $('#main').append('&lt;img src="img/ajax-loader.gif" class="loaderIcon" alt="Loading..." /&gt;'); var name = $('input#name').val(); var email = $('input#email').val(); var phone = $('input#phone').val(); var message = $('textarea#message').val(); $.ajax({ type: 'post', url: 'sendEmail.php', data: 'name=' + name + '&amp;email=' + email + '&amp;phone=' = phone + '&amp;comments=' + comments, success: function(results) { $('#main img.loaderIcon').fadeOut(1000); $('#response').html(results); } }); // end ajax }); </code></pre> <p>});</p> <p>All I want is users to see a simple thank you page after they fill out the form.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload