我有一个php表单,它工作得很好。确认电子邮件发送给用户,但我希望它在消息之前张贴姓名。它现在不会公布这个名字。只是发布消息。我想让它说一些类似的话。,谢谢你全名(然后留言)任何帮助都会让人大吃一惊。
// Subject of confirmation email.
$conf_subject = 'Test Message';
// Who should the confirmation email be from?
$conf_sender = 'Test <no-reply@test.com>';
$msg .= $_POST['Full_Name']."'n";
$msg = "Thank you for your recent inquiry If you have any questions please call us at 555-555-5555 'n'n";
mail( $_POST['Email_Address'], $conf_subject, $msg, "From: $conf_sender" );
如果我正确理解这一点,您只需要在字符串中插入一个变量。
$name = $_POST['Full_Name'];
$msg = "Thank you ".$name." for your recent inquiry If you have any questions please call us at 555-555-5555 'n'n";
http://php.net/manual/en/language.operators.string.php
在代码中,您将full_name添加到$msg中。然后将变量的内容替换为消息:
$msg .= $_POST['Full_Name']."'n";
$msg = "Thank you for your recent inquiry If you have any questions please call us at 555-555-5555 'n'n";
在这段代码中,您首先使用full_name设置$msg,然后添加消息的其余部分。
$msg = $_POST['Full_Name']."'n";
$msg .= "Thank you for your recent inquiry If you have any questions please call us at 555-555-5555 'n'n";