• Hi – My website is wwww.pearsonkoutcherlaw.com.

    I have created a contact form using PHP

    if (isset($_POST['formSubmit'])) {
    
        $webMaster = " [email protected]";    
    
        $name = $_POST['formName'];
        $email = $_POST['formEmail'];
        if (isset($_POST['formPhone']))
            $phone = $_POST['formPhone'];
        else
            $phone = "";
        if (isset($_POST['formMessage']))
            $message = $_POST['formMessage'];
        else
            $message = "";
        $ip=$_SERVER['REMOTE_ADDR'];
    
        //Subject & Email Varibles
        $emailSubject = 'Pearson Contact Us'; // Choose A Email Subject
    if(!empty($_POST['email'])) $spam=true;
    
        $body = <<<EOD
    
    <hr></hr>
    <h1>$emailSubject</h1>
    <hr><br>
    <strong>Name:</strong><br>
    $name <br><br>
    
    <strong>Email:</strong><br>
    $email <br><br>
    
    <strong>Phone:<br>
    $phone <br><br>
    
    <strong>Message:</strong><br>
    $message <br><br>
    
    <strong>IP Address Of Sender:</strong><br>
    $ip <br><br>
    
    <hr>
    
    This is the email from your site.
    
    EOD;
        $headers = "From: $email\r\n";
        $headers .= "Content-Type: text/html\r\n";
        $success = mail($webMaster, $emailSubject, $body, $headers);
    }
    
    get_header(); ?>
    
    	<div id="mid" class="container">
            <div id="left">
                <div id="content">
                    <div class="RichText">
    <div style="margin-left: -250px"><h1><span style="color: black; font-size: 32px;"><strong><center>PearsonKoutcher Law provides superior legal services to Injured Workers in <span style="font-weight: bold; color: red;"><br/>ALLENTOWN, LEHIGH VALLEY and BETHLEHEM, PA!</center></strong></span></div></h1>
    <div style="margin-left: -200px"><h2><span style="color: black; text align: center;"><center>CALL US NOW FOR A<span style="font-size: 32px; font-weight: bold; color: red;"> FREE</span>, WORKERS' COMP CONSULTATION: </center></span><span style="color: red; font-size: 42px;"><strong><center>215-391-4963.</strong></center></span></h2></div>
    
                        <?php
                        if (isset($_POST['formSubmit'])) {
                            print "<p style=\"font-weight:bold;\">Form has been sent!</p>";
                            print '<p>Thank you for your submission. </p>';
                            print "<p>What You Sent</p>";
    
                            print "<b>Name:</b><br/>".$name."<br/><br/>";
                            print "<b>Email:</b><br/>".$email."<br/><br/>";
                            print "<b>Phone:</b><br/>".$phone."<br/><br/>";
                            print "<b>Message:</b><br/>".$message."<br/><br/>";
    
                        } else {      ?>
    
    <div style="position: relative; right: -50px; "> <form action="" method="post" name="contact_form2" enctype="application/x-www-form-urlencoded" onsubmit="return validateForm2();">
    
    <div class="special">
        <label for="cfSpecial">
            Special<br /><input value="" name="special" id="cfSpecial" class="text" type="text" eform="Special:date:0"  /></p>
        </label>
    </div>
    
    <table>
    
    <tbody>
    
    <tr>
    			<td>Your Name (*)</td>
                            <td><input id="name" name="formName" type="text" ></td></tr>
                          <tr><td>  Your Email (*)</td>
                           <td> <input id="email" name="formEmail" type="text" value=""></td></tr>
                           <tr><td>   Your Phone (*)</td>
                           <td> <input id="phone" name="formPhone" type="text" value=""></td></tr>
                           <tr><td> Message</td>
                           <td> <textarea id="message" name="formMessage" cols="17" rows="5"></textarea><br/>
    
    <input type="text" id="not_human" name="name" style="display: none" /> 
    
      <input type="submit" name="formSubmit" id="formSubmit" value="submit"  /> </td></tr>
      </table></div>

    After submitting, this stays on the same URL and generates a thank you message. Instead, I would like to redirect to a different URL? Can someone please help me with this?

    Thanks,

    Megan

Viewing 1 replies (of 1 total)
  • Thread Starter mrmccarrin

    (@mrmccarrin)

    Hello again,

    I added this code:

    header("location: https://www.pearsonkoutcherlaw.com/abl-form-submit/"); exit;

    to

    <?php
                        if (isset($_POST['formSubmit'])) {
    			header("location: https://www.pearsonkoutcherlaw.com/abl-form-submit/"); exit;
                            print "<p style=\"font-weight:bold;\">Form has been sent!</p>";
                            print '<p>Thank you for your submission. </p>';
                            print "<p>What You Sent</p>";
    
                            print "<b>Name:</b><br/>".$name."<br/><br/>";
                            print "<b>Email:</b><br/>".$email."<br/><br/>";
                            print "<b>Phone:</b><br/>".$phone."<br/><br/>";
                            print "<b>Message:</b><br/>".$message."<br/><br/>";
                        } else {      ?>

    And it is now redirecting me correctly, however, I am now wondering how I get the following to appear on my newly directed page?

    `print “<p style=\”font-weight:bold;\”>Form has been sent!</p>”;
    print ‘<p>Thank you for your submission. </p>’;
    print “<p>What You Sent</p>”;

    print “<b>Name:</b><br/>”.$name.”<br/><br/>”;
    print “<b>Email:</b><br/>”.$email.”<br/><br/>”;
    print “<b>Phone:</b><br/>”.$phone.”<br/><br/>”;
    print “<b>Message:</b><br/>”.$message.”<br/><br/>”;
    } else { ?>

    Thank you.

    Megan

Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting Contact Form after Submission’ is closed to new replies.