2
I have a script that sends a newsletter, at that moment I get a page . php by
file_get_contents('news.php')
On the news.php page I tried to get the variable using this:
$email = $_REQUEST['email'];
On this page news.php I created a link below the document where the user can decadastrar the newsletter, but I am not able to rescue the value of the email to pass as parameter, my the link of the news page. php is like this:
Para cancelar o recebimento deste boletim, <a href="http://www.moveissaobento.com.br/unsubscribe.php?e=<?php echo $email ?>"> Clique aqui </a> e vamos removê-lo da lista imediatamente.
The script that sends the news is like this:
while($row = $result->fetch_array()) {
$id = $row['id'];
$email = $row['email'];
$mail->setFrom('[email protected]', 'Newsletter');
$mail->addAddress($email);
$mail->Subject = 'Envio Newsletter';
$mail->msgHTML(file_get_contents('news.php'), dirname(__FILE__));
$mail->send();
$mail->ClearAddresses();
$stmt = $mysqli->prepare("UPDATE newsletter SET enviado = 1 WHERE id = $id");
$stmt->execute();
}
I couldn’t visualize a solution.
you need to send a post with these variables.
– rray
You just forgot to pass the parameter to the page... Try it this way: file_get_contents("news.php?email=$email"); and change your $_REQUEST to $_GET;
– Rafael Withoeft
Hello @Rafaelwithoeft, I received an error message when passing the parameter as indicated, see: Message body Empty.
– adventistapr
@adventistapr I believe this to be a Mailer error, no page... check it out: http://stackoverflow.com/questions/13816571/phpmailer-mailer-error-message-body-empty or have you checked what’s coming back from file_get_contents? var_dump(...)
– Rafael Withoeft
Hello @Rafaelwithoeft, now I managed to do following your tip.
– adventistapr
@adventistapr If you want more security, you can use POST, but if you continue to use GET, I recommend filtering what you get on the page using filter_input (http://php.net/manual/en/function.filter-input.php)
– Rafael Withoeft
Hello @Rafaelwithoeft, I’m using the POST, thanks for the tip.
– adventistapr