Newsletter php (email with empty fields)

3

Can anyone help me please?

I saw this on the net and tried to take advantage of it, however in my email I get the fields "Name:" and "Email:" but they are completely empty, but when sending I send with the fields filled!

index.html

<form method="POST" action="newsletter.php">
                        <li>
                            <input type="text" class="text" value="Nome">
                        </li>
                        <li>
                            <input type="text" class="text" value="Email">
                        </li>
                            <input type="submit" value="submit">
                    </form>

newsletter.php

# RESULT PAGE
$location = "";

## FORM VALUES ##

# SENDER - WE ALSO USE THE RECIPIENT AS SENDER
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!
# SEE ALSO: How to protect a php Email Form using php mail or mb_send_mail against Mail Header Injection
$sender = $recipient;

# MAIL BODY
$body = "Name: ".$_REQUEST['Nome']." \n";
$body = "Email: ".$_REQUEST['Email']." \n";
# add more fields here if required

## SEND MESSGAE ##

mail($subject, $body, "From: $sender" ) or die ("O email não pode ser enviado.");

## SHOW RESULT PAGE ##

header( "Location: $location" );
?>

Thank you

    
asked by anonymous 25.03.2015 / 21:05

1 answer

6

The name attribute is missing from its inputs.

<input type="text" class="text" value="Nome" name="Nome">
<input type="text" class="text" value="Email" name="Email">

Not to mention php that replaces the contents of $body the second time you assign value to it. The right thing would be something like this:

$body = "Name: ".$_REQUEST['Nome']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
    
25.03.2015 / 21:18