最好的方法是从表单中检索值,然后通过电子邮件发送这些值:
注意:我没有以任何方式清理输入 - 所以如果您要使用数据库,请确保清理它们!
登陆页面.html
<form name="create_landing_page" action="/landing-page/" method="get">
<input name="email_address" value="Enter your email" />
<input name="name" value="Enter your name" />
</form>
登陆页面(.php)
if(isset($_GET['email_address']) && !empty($_GET['email_address'])){
$emailAddress = $_GET['email_address'];
}
if(isset($_GET['name']) && !empty($_GET['name'])){
$name= $_GET['name'];
}
$to = $emailAddress;
$subject = 'the subject';
$message = 'hello ' . $name;
$headers = 'From: youremail@example.com' . "\r\n" .
'Reply-To: youremail@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(!mail($to, $subject, $message, $headers))
{
die('There was an error sending out the email');
}