用于收集数据的html表单
<form method="post" action="test.php" name="f2" onSubmit="return contact_validate1(this)">
<ul>
<li>
<label>Name :</label>
<input name="name" type="text" required>
</li>
<li>
<label>Email :</label>
<input name="email" type="email" required placeholder="Enter Your Valid Email">
</li>
<li>
<label>Mobile :</label>
<input name="mobile" type="text" required pattern="[0-9]{10,}$" placeholder="Enter Your Mobile Number">
</li>
<li>
<input name="" class="submit" type="submit" value="">
</li>
</ul>
</form>
test.php //获取值
<?php
error_reporting(0);
$name=$_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$headers = "From: training@smeclabs.com \nReply-To: ".$email."\n";
$headers .= "MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1";
$msg="<table><tr><td>Name: ".$name."</td></tr><tr><td>Email: ".$email."</td></tr><tr><td>Mobile Number: ".$mobile."</td></tr></table>";
/* if($_SESSION["captcha"]==$_POST["captcha"])
{*/
if(mail("training@myweb.com","Form Record Received",$msg,$headers))
//$msg1="Email Sent Successfully";
header( "Location:$location" );
header("location:formsubmit.html");
?>
我想在此表单中添加短信api
例如:
http://smsad.smsapiindia.com/SendSms.aspx?username=xxx&password=xxx&to=$mobile&from=xxxx&message=Thank You for Contacting
没有标题位置 并仅显示当前标题位置formsubmit.html
答案 0 :(得分:0)
使用cURL
提交数据..
$url="http://smsad.smsapiindia.com/SendSms.aspx?username=xxx&password=xxx&to=$mobile&from=xxxx&message=Thanks";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$auth = curl_exec($curl);
if($auth)
{
if(mail("training@myweb.com","Form Record Received",$msg,$headers))
header( "Location:$location" ); //Some "success.php"
exit;
//header("location:formsubmit.html");
}
}