Help PHP Form

-2

I have the following code:

<?php

// Do not edit this if you are not familiar with php
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post) {
    function ValidateEmail($email){

        $regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^";
        $eregi = preg_replace($regex,'', trim($email));

        return empty($eregi) ? true : false;
    }

    $name = stripslashes($_POST['ContactName']);
    $to = trim($_POST['to']);
    $email = strtolower(trim($_POST['ContactEmail']));
    $subject = stripslashes($_POST['subject']);
    $message = stripslashes($_POST['ContactComment']);
    $error = '';
    $Reply=$to;
    $from=$to;

    // Check Name Field
    if(!$name) {
        $error .= 'Please enter your name.<br />';
    }

    // Checks Email Field
    if(!$email) {
        $error .= 'Please enter an e-mail address.<br />';
    }
    if($email && !ValidateEmail($email)) {
        $error .= 'Please enter a valid e-mail address.<br />';
    }

    // Checks Subject Field
    if(!$subject) {
        $error .= 'Please enter your subject.<br />';
    }

    // Checks Message (length)
    if(!$message || strlen($message) < 3) {
        $error .= "Please enter your message. It should have at least 5 characters.<br />";
    }

    // Let's send the email.
    if(!$error) {
        $messages="From: $email <br>";
        $messages.="Name: $name <br>";
        $messages.="Email: $email <br>";    
        $messages.="Message: $message <br><br>";
        $emailto=$to;

        $mail = mail($emailto,$subject,$messages,"from: $from <$Reply>\nReply-To: $Reply \nContent-type: text/html");    

        if($mail) {
            echo 'success';
        }
    } else {
        echo '<div class="error">'.$error.'</div>';
    }

}
?>

Can anyone tell me where to enter my email address to receive the data from this form?

    
asked by anonymous 22.01.2017 / 00:51

1 answer

0

I see that you do not know php's mail function

mail(string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]]);

$to = Recipient of the email in question

In your code $emailto=$to; refers to the receiver, $to is coming from $_POST of another form

  

Can anyone tell me where to enter my email address to receive the data from this form?

You can send a copy to you by putting your email as one of the recipients:

$to=trim($_POST['to']).',';
$to.='[email protected]';

Or you can change to send only to your email, in this case it would be interesting to remove the input[name='to'] form that sends information to this email

$to='[email protected]';

By simply changing line 16 of your code

    
22.01.2017 / 00:59