Jump to content

Recommended Posts

Hi

 

I have gotten this contact form, and it works normally on its full url (http://www.mdoneonone.com/includes/contact_short.php). But when I put it in with the template and submit I get an internal server error. here is the final url (http://www.mdoneonone.com/contact-deborah-harding.html)

 

Here is the code for it:

 

<?php session_start(); ?><center>

<?php

echo "$status2";

?>

<?php




// Change these two variables to meet your needs.



$myemail = '';

$subject = $fname && $lname;



$op = $_POST[op];



if($op == 'contact')

{
   if (isset($_POST['submitBtn'])){
      $secCode = isset($_POST['secCode']) ? strtolower($_POST['secCode']) : "";
      if ($secCode == $_SESSION['securityCode']) {

         unset($_SESSION['securityCode']);
         $result = true;
      }
      else {
         $status = "<p>Sorry the security code is invalid! Please try it again!</p>";
         $result = false;
      }
   }


    $fname = stripslashes($_POST[fname]);





    $fname = stripslashes($_POST[fname]);

    $azip = stripslashes($_POST[azip]);

    $astate = stripslashes($_POST[astate]);

    $adress1 = stripslashes($_POST[adress1]);

    $address_2 = stripslashes($_POST[address_2]);

    $lname = stripslashes($_POST[lname]);

    $city = stripslashes($_POST[city]);

    $email = stripslashes($_POST[email]);

    $bmonth = stripslashes($_POST[bmonth]);

    $byear = stripslashes($_POST[byear]);

    $bday = stripslashes($_POST[bday]);

    $remail = stripslashes($_POST[remail]);

    $gender = stripslashes($_POST[gender]);

    $phone_1 = stripslashes($_POST[phone_1]);

    $phone_2 = stripslashes($_POST[phone_2]);

    $phone_3 = stripslashes($_POST[phone_3]);

    $text = stripslashes($_POST[text]);

    $referer = $_POST[referer];

    $remote_host = $_SERVER[REMOTE_ADDR];

    $server = $_SERVER[sERVER_NAME];

    $browser = $_SERVER[HTTP_USER_AGENT];



      if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email)) 

    { 

        $status = "We're sorry, but you've entered an incorrect email address.<br>";

    }

    if(!$fname)

    {

        $status .= "Please enter your first name.<br>";

    }

    if(!$lname)

    {

        $status .= "Please enter your last name.<br>";

    }

     if($email != $remail)

{

$status .= "Your emails do not match.";

}









if(!$text) 

    {

        $status .= "Please enter a message.<br>";

    }





    if(!$status)

    {

        $header = "From: $email\r\nReply-To: $email\r\n";



        $message = "



--------Name--------



First Name: $fname

Last Name: $lname





------Email-----------



Both Emails should match



Email: $email

Email: $remail

  

----------------------------

Message: $text



--------------------------------------------

Below Must be mdoneonone.com

            Referer: $referer

            Site: $server

            Remote Host: $remote_host

            Remote Browser: $browser



           Copy of message: $text

        ";

       if(mail($myemail, $subject, $message, $header))

        {

	    $status2 = "";

            $status = "<font color='black'>Thank you, Your message has been sent!<br><br></font>";



        }

        else

        {

            $status = "There was a problem sending your feedback, please try again.<br><br>";

        }



    }

    else

    {

        $status .= "<br>Please press <u>back</u> on your browser to resubmit.<br><br>";

    }

}    



// Now check the referer page and ensure it's a proper URL



$referer = $_SERVER[HTTP_REFERER];



if(!preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $referer))

{

    unset($referer);

}







?>





<h2>Contact Deborah Harding Instantly</h2><br />

<font color="red"><?php print $status; ?></font>

<?php if ((!isset($_POST['submitBtn'])) || (!$status)){
?>  

<form method="post" action="<?php print $_SELF; ?>">

<input type="hidden" name="op" value="contact">

<input type="hidden" name="referer" value="<?php print $referer; ?>">



First Name:<input name="fname" size="15" value="">

Last Name:<input name="lname" size="15" value=""><br><br>

  E-mail address:<input name="email" size="35" value=""><br><br />

Re-enter E-mail:<input name="remail" size="35" value="">





<br />
        <table width="400">
          <tr><td>Security code: <input class="text" name="secCode" type="text" size="10" /></td>
              <td><img src="http://www.mdoneonone.com/images/securityCode.php" alt="security code" border="1" /></td>
          </tr>
          <tr><td colspan="2" align="center"><br /></td></tr>
        </table>  
      
<br />

<br />



<b>Type Your Message:</b>



<br><textarea name="text" cols="50" rows="10"></textarea><br><br>

<input name="submitBtn" type="submit" value="Send message!">

</form><?php
   } else {} 
?> </center>

 

If you guys could help me I will owe you my foot.  ;D

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/88292-cant-get-this-thing-to-work/
Share on other sites

hello mate there are a few issues there loool unfortunatly some are important some are not;)

 

Change: from the <form> tag

 

 print $_SELF;

to

echo $_SERVER['PHP_SELF']

 

 

The page is also on html base instead of php lool

http://www.mdoneonone.com/includes/contact_short.php

http://www.mdoneonone.com/contact-deborah-harding.html

Not sure if that would make a difference but worthed checking:)

 

also on mail headers you do not have enough headers in it sometimes emails may be rejected if there are not enough headers on the "$header" variable.

 

They are two diffrent pages i wonder if both pages have the same script as you have posted here if not then you are telling on submit they should be on the same page not to go on a different page.

 

Duno if i am making much sense but hope u find it helpful

hello mate there are a few issues there loool unfortunatly some are important some are not;)

 

Change: from the <form> tag

 

 print $_SELF;

to

echo $_SERVER['PHP_SELF']

 

 

The page is also on html base instead of php lool

http://www.mdoneonone.com/includes/contact_short.php

http://www.mdoneonone.com/contact-deborah-harding.html

Not sure if that would make a difference but worthed checking:)

 

also on mail headers you do not have enough headers in it sometimes emails may be rejected if there are not enough headers on the "$header" variable.

 

They are two diffrent pages i wonder if both pages have the same script as you have posted here if not then you are telling on submit they should be on the same page not to go on a different page.

 

Duno if i am making much sense but hope u find it helpful

 

I changed the <?php session_start(); ?>, and is not the base .html (its on a rewrite engine). What do you mean by the headers being rejected?

 

Thanks for the help

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.