我有一个叫做addcustomer.php的表单。它包含第一名,姓,手机字段。我也有这个表单上的2个按钮。用于保存数据的onr按钮和用于向客户发送短信的其他按钮。 我想当我点击第二个按钮3数据字段传递给另一个形式称为smsinfo.php。 现在保存数据的操作很好,但直接发送到smsinfo。此表单上没有数据。 smsinfo.php的2种不同的动作形式
<form method ="POST" name = "custform" action="">
<div class="cell_2_2"><label class="lblfields">Firstname:</label> <input type="text" name="firstname" autocomplete="off"/></div>
<div class="cell_3_2"><label class="lblfields">Lastname :</label> <input type="text" name="lastname" autocomplete="off"/></div>
<div class="cell_5_2"><label class="lblfields">Mobile :</label> <input type="text" name="mobile" autocomplete="off"/></div>
<input type="submit" name="submit" value="Save"/>
<input type="submit" name="sendsms" value="Sms"/>
if (isset($_POST['submit']))
{
Saving code here
} else if (isset($_POST['sendsms'])) {
header("Location: smsinfo.php");
}
这里代码:
<?php
$Fname = $_REQUEST['firstname'];
$Lname = $_REQUEST['lastname'];
$Mob = $_REQUEST['mobile'];
?>
<html>
<body>
<form action="sendingsms.php" method="POST">
<input style="width: 100px;" name="firstname" type="text" value="<?php echo $firstname; ?>"/>
<input style="width: 100px;" name="lastname" type="text" value="<?php echo $lastname; ?>"/>
<input style="width: 100px;" name="mobile" type="text" value="<?php echo $mobile; ?>"/>
</form>
</body>
</html>
感谢我的英文不好
header(“Location:smsinfo.php”);不发送数据 为什么不把短信内置于if(isset($ _ POST ['submit']))的else子句中? –
如果您必须使用标头(“位置:smsinfo.php”)进行重定向,则可以将表单数据附加到标头中的URL(“位置:smsinfo.php”)。 – birraa
你可以使用js吗? –