Jump to content

[SOLVED] Help with contact code


Sebolains

Recommended Posts

Hey guys. I had this code for a contact page that sent an email to me with the information that people filled in in the form. It used to work perfectly, but now I've changed hosts and it doesn't work anymore. Everything else in the site works perfectly. I'm going insane trying to see why this is. See if you can pleaase give me a hand. Here's the code:

<h2>Contact Us</h2>

<br>

<?php

$myemail = 'myemailadress@yahoo.com';
$subject = 'Contact form Subject';

$op = $_POST[op];

if($op == 'contact')
{
    $name = stripslashes($_POST[name]);
    $email = stripslashes($_POST[email]);
    $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(!$name)
    {
        $status .= "Please enter your name.<br>";
    }
    if(!$text)
    {
        $status .= "Please enter a message.<br>";
    }

    if(!$status)
    {
        $header = "From: $emailrnReply-To: $emailrn";

        $message = "
            Name: $name
            Referer: $referer
            Site: $server
            Remote Host: $remote_host
            Remote Browser: $browser

            $text
        ";

        if(mail($myemail, $subject, $message, $header))
        {
            $status = "Thank you for your Feedback!!<br><br>";
        }
        else
        {
            $status = "There was a problem sending your feedback, please try again later.<br><br>";
        }

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

$referer = $_SERVER[HTTP_REFERER];

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

?>

<?php print $status; ?>

<form method="post" action="<?php print $_SELF; ?>">
<input type="hidden" name="op" value="contact">
<input type="hidden" name="referer" value="<?php print $referer; ?>">
Name<br><input name="name" size="35" value=""><br>
E-mail address<br><input name="email" size="35" value=""><br>
<br>Message<br><textarea name="text" cols="50" rows="10"></textarea><br><br>
<input type="submit" value="Send message!">
</form>

 

the problem is that I get the message error whenever I try to use it.

 

Thanks a million for your contributions!!

Link to comment
Share on other sites

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

 

eregi() is deprecated use PCRE instead of POSIX.

 

add $status = ''; before the if (!eregi()) and change

 

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

 

to

 

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

 

What is the specific problem does it output:

 

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

Link to comment
Share on other sites

First of all, thanks for your help.

 

I tried doing your suggested changes, but the same thing keeps happening. And yes: the problem is that it keeps outputting

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

 

 

Thank you so much for your help. I'll keep trying to see whether I can come up with what's wrong.

Link to comment
Share on other sites

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.