gpt4 book ai didi

复选框html表单的php代码

转载 作者:太空宇宙 更新时间:2023-11-04 15:35:05 24 4
gpt4 key购买 nike

这是我第一次来这里,所以请多多包涵..这是我的 html 表单:

<form method="post" action="contactformprocess.php">
<input id="name" name="name" type="text" value="" />
<br />
<input id="phone" name="phone" type="text" value=" /><br />
<input id=" email " name="email " type="text " value=" " /><br />
<textarea rows="5 " id="message " name="message " cols="20 "></textarea><br />
<input id="submit " name="submit " value="שלחו " type="submit " ><br />
<input id="checkbox " type="checkbox " checked="yes " value="i want
to recive weekly updates from you "/> i want to recive weekly updates from you <br />
</form>

这是我使用的 php 代码:

<?php
$emailSubject = '.....';
$webMaster = 'aa@aa';

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];

$body = <<<EOD
<br><hr><br>
Subject: $option<br>
Name: $name <br>
Phone: $phone<br>
Email: $email <br>
Message: $message <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
?>

我缺少的是验证复选框是未选中(已设置为已选中)还是已选中并将信息与其他字段一起发送的 php 脚本。如果选中发送"is",如果取消选中发送“否”或什么都不发送。谢谢 :)

最佳答案

几个问题...您的复选框没有定义名称,因此您不会在帖子中看到它。你会希望它看起来更像:

<input id="checkbox" type="checkbox" name="updates" checked="checked" value="yes"/> i want to recive weekly updates from you <br />

如果复选框未选中,则不会包含在帖子中,因此您的 php 可能是:

$updates = isset($_POST['updates']) ? 'Yes' : 'No';

关于复选框html表单的php代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9875465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com