sending email with the click of a button with data from different page

i have an admin page that collects the data from a form user submitted in the form of a table . i want to have a button that recognize the user email column when clicked and send them a premade email.

of course ive looked around but all of the ones with similar problem as me have it so their form is also in the same page as the button so they can do $_POST and mailto. i cant do that because the form is in different page.

this is the table where admin sees user info

<td><?php echo $v['telephone']; ?></td>
<td><?php echo $v['email']; ?></td>
<td><?php echo $v['website']; ?></td>

and then this is the button an admin would press to send it

<input type="submit" value="Send confirmation" />
<input type="hidden" name="button_pressed" value="1" />

and under it is the php code to send it

<?php

if(isset($_POST['button_pressed']))
{
$to      = $v['email'];
$subject = 'ayayay';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

echo 'Email Sent.';
}

?>  

nothing seems to happen when i click it. and of course i dont actually get the email either. What am i missing here?

i have header tag up above either, not sure if it actually does anything for this page but i looked around and they said it might help but it didnt

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

Thank you

Can you expand on that? Do you mean that nothing happens when you click the button, you don’t get a blank screen? Do you have the correct <form> tags around your inputs as you would have done in your registration form, and is the action parameter correct?

Oh, do you just mean it’s underneath it in the PHP script? That won’t work. You need to put that in a separate file, and point to it with your <form> tag. You could have it in the same one, if you wanted, but put that code at the top rather than after the HTML. You’ll still have to pass the variables through somehow, because when you press the button it will cause the script (either the same one, or a different one, depending on the action parameter of your form tag) to be reloaded.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.