Jump to content

Recommended Posts

Hi, 

 

i have a contact form with this code: 

<?php
if(isset($_POST['submit']))
{
$flag=1;
if($_POST['yourname']=='')
{
$flag=0;
echo "Please Enter Your Name<br>";
}
else if(!preg_match('/[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*/',$_POST['yourname']))
{
$flag=0;
echo "Please Enter Valid Name<br>";
}
if($_POST['email']=='')
{
$flag=0;
echo "Please Enter E-mail<br>";
}
else if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['email']))
{
$flag=0;
echo "Please Enter Valid E-Mail<br>";
}
if($_POST['subject']=='')
{
$flag=0;
echo "Please Enter Subject<br>";
}
if($_POST['message']=='')
{
$flag=0;
echo "Please Enter Message";
}
if ( empty($_POST) )
{
print 'Sorry, your nonce did not verify.';
exit;
}
else
{
if($flag==1)
{

wp_mail(get_option("admin_email"),trim($_POST[yourname])." sent you a message from StraightForwardLegal.com".get_option("blogname"),stripslashes(trim($_POST['message'])),"From: ".trim($_POST['yourname'])." <".trim($_POST['email']).">\r\nReply-To:".trim($_POST['email']));
echo "Thank you for contacting us!<br>  We have received your email. <br> One of our Workers' Compensation Attorneys <br> will be in touch with you as soon as possible";
header ("location: http://www.straightforwardlegal.com"); exit;
}
}
}
?>

and then, 

<div class="frontForm">
<form method="post" id="contactus_form"><span style="font-size: 12px;>
                    <div class="left">
Name*:<br><input type="text" name="yourname" id="yourname" rows="1" maxlength="35"><br>
Email*:<br><input type="text" name="email" id="email" rows="1" value=""><br>
Phone*:<br><input type="text" name="subject" id="subject" rows="1" columns="8" style= "max-height: 18px; min-height: 18px;" value="" /></td></tr>
</div>
 <div class="right" style="margin-top: -120px;"/>
Message*:<textarea name="message" id="message" rows="5" style="height: 90px;"></textarea><br><br>
<input type="submit" name="submit" id="submit" value="Send"/></span>
</form>
           
            </div>
        </div>

    </div>
</div>

I used 

header ("location: http://www.straightforwardlegal.com"); exit;

but, it does not work.  After submitting my contact form, the user gets taken to my contact page instead of going to my home page?  I was wondering if someone could let me know what I have done wrong?

 

Thank you, 

 

Megan 

Have you tried adding some debugging statements to see where the script is ending? For example:

<?php
//...
 
     if($flag==1)
     {
          echo '<div>here (flag==1)</div>';
 
 
          wp_mail(get_option("admin_email"),trim($_POST[yourname])." sent you a message from StraightForwardLegal.com".get_option("blogname"),stripslashes(trim($_POST['message'])),"From: ".trim($_POST['yourname'])." <".trim($_POST['email']).">\r\nReply-To:".trim($_POST['email']));
          echo "Thank you for contacting us!<br>  We have received your email. <br> One of our Workers' Compensation Attorneys <br> will be in touch with you as soon as possible";
          //header ("location: http://www.straightforwardlegal.com");
          exit;
     }
 
     echo '<div>here (flag!=1)</div>';
 
//...
?>

Also, do you have PHP set to show all errors and warnings? If not, enabling them may provide a clue. You can enable all errors and warnings by adding the following to your script:

<?php
//REPORT ALL PHP ERRORS
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
 
Of course, you'll want to remove the above code once everything is fixed.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.