左侧对联用于实现短信挂号效果制作

左侧对联效果

1. js文件实现的功能:

(1)  添加左侧弹框,并且固定在具体位置;

(2)  添加条件判断,判断用户名,手机号等有效性等功能;

(3) 面板写入各种控件

// JavaScript Document
//左侧

//删除用户cookie
function cookie_delete(name) {
var cookie = getcookie(name);

if (typeof (cookie) != 'undefined') {
document.cookie = name + "=" + cookie + ";path=/";
} else {
document.cookie = name + "=;path=/";
}
}
//添加tid到cookie
function cookie_add(name) {
var handle = getcookie(name);

var exdate = new Date();
exdate.setDate(exdate.getDate() + 1);
document.cookie = name + '=' + handle + ";expires=" + exdate.toUTCString() + "path=/";
}
//获取指定名称的cookie的值
function getcookie(objname) {
var arrstr = document.cookie.split("; ");
for (var i = 0; i < arrstr.length; i++) {
var temp = arrstr[i].split("=");
if (temp[0] == objname)
return unescape(temp[1]);
}
return '';
}
//判断是否注册次数过多
function illWill2()
{
var date=new Date();
var expiresDays=1;
//将date设置为1天以后的时间
date.setTime(date.getTime() + expiresDays*24*3600*1000);

if (getcookie('illWill')==''){
document.cookie="illWill=1;expires="+date.toGMTString();
}
else if(getcookie('illWill')=='1')
{
document.cookie="illWill=2;expires="+date.toGMTString();
}
else if(getcookie("illWill")=='2')
{
document.cookie="illWill=3;expires="+date.toGMTString();
}
else if(parseInt(getcookie("illWill"))>=3)
{
return false;
}
return true;
}
function smsbeforeSubmit(form) {
if (form.custname.value == '') {
alert('用户名不能为空!');
form.custname.focus();
return false;
}
if (form.mobileno.value.length != 11 ) {
alert('请输入正确手机号!');
form.mobileno.focus();
return false;
}
var myreg = /^((13|14|15|16|17|18|19|)+\d{9})$/;
if(!myreg.test(form.mobileno.value))
{
alert('请输入有效的手机号码!');
form.mobileno.focus();
return false;
}

if (form.scheduletime.value.length < 1) {
alert('预约时间不能为空!');
form.scheduletime.focus();
return false;
}
if(illWill2()==false)
{
alert('您已经成功挂号!');
return false;
}
form.swebsite.value = this.location.href;
return true;
}

 

function hide(obj){
var my_img=document.getElementById("lovexin12");
my_img.style.display=my_img.style.display=="none"?"inline-block":"none";
}

function swtClick()
{
LR_HideInvite();
openZoosUrl();
return false;
}

document.write("<form method=\"post\" action=\"http://www.czmebel.com/mail_mebel/mebel_sms.php\" onSubmit=\"return smsbeforeSubmit(this);\" style=\"left: 0;position: fixed !important;top: 110px;z-index: 2147483647;LEFT: expression(eval(document.compatMode && document.compatMode=='CSS1Compat')?(documentElement.scrollLeft + 0):(document.body.scrollLeft + 0));MARGIN-LEFT: 0px;POSITION: absolute;TOP: 110px;_TOP: expression(eval(document.compatMode && document.compatMode=='CSS1Compat')?(documentElement.scrollTop + 110):(document.body.scrollTop + 110));}; background:url('http://www.czmebel.com/swt/smsguahao.gif');height:400px; width:160px;\" id=\"lovexin12\">");
document.write("<input type=\"text\" style=\"width:80px; margin-top:220px; margin-left:50px;\" name=\"custname\" />");
document.write("<div style=\"clear:both; height:10px;\"></div>");
document.write("<input type=\"text\" style=\"width:100px;margin-left:50px;\" name=\"mobileno\" />");
document.write("<div style=\"clear:both; height:6px;\"></div>");
document.write("<input type=\"date\" style=\"width:100px;margin-left:50px;\" name=\"scheduletime\" />");
document.write("<div style=\"clear:both; height:3px;\"></div>");
document.write("<input type=\"text\" name=\"swebsite\" style=\"display:none;\" />");
document.write("<input type=\"submit\" style=\"width:140px;margin-left:10px; height:33px;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;\" value=\"\">");
document.write("</form>");

 

2. PHP文件

 

<?php
/*--------------------------------
功能: PHP HTTP接口 发送短信
修改日期: 2013-05-08
说明: http://m.5c.com.cn/api/send/?username=用户名&password=密码&mobile=手机号&content=内容&apikey=apikey
状态:
发送成功 success:msgid
发送失败 error:msgid

注意,需curl支持。

返回值 说明
success:msgid 提交成功,发送状态请见4.1
error:msgid 提交失败
error:Missing username 用户名为空
error:Missing password 密码为空
error:Missing apikey APIKEY为空
error:Missing recipient 手机号码为空
error:Missing message content 短信内容为空
error:Account is blocked 帐号被禁用
error:Unrecognized encoding 编码未能识别
error:APIKEY or password error APIKEY 或密码错误
error:Unauthorized IP address 未授权 IP 地址
error:Account balance is insufficient 余额不足
error:Black keywords is:党中央 屏蔽词
--------------------------------*/
header('Content-Type:text/html;charset=utf-8');

//客户信息录入

$custname=$_POST['custname'];
$smobile=$_POST['mobileno'];
$stime=$_POST['scheduletime'];
$website=$_POST['swebsite'];

echo $website;
//公共信息录入
$username = 'meiniu'; //用户账号
$password = 'password'; //密码
$apikey = 'apikey'; //APIKEY
$mobile = '18xxxxxxxxx,'.$smobile; //号手机码
$content = '【美贝尔医疗美容医院】'.$custname;
$content = $content.'您好,常州美贝尔医疗美容医院提醒您已经成功预约,预约号为:';
//根据当前时间获取预约号
$yyno=strtotime("now");
$content = $content.$yyno;
$content = $content.',预约时间为:';
$content = $content.$stime;
$content = $content.',您来院会有工作人员核对姓名和预约号。地址:常州市怀德北路53号。如有疑问请咨询:0519-86636999';//内容

//即时发送
echo $content;
$result = sendSMS($username,$password,$mobile,$content,$apikey);
echo $result;

//数据库插入操作
$con = mysql_connect("localhost","root","mebel");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
/*
else
{
echo "connect!";
}
*/
$db_selected = mysql_select_db("mebelzx",$con);
mysql_query('SET NAMES UTF8');
$sql = "insert into szmbe2_ghmessage(username,mobileno,scheduledate,content,website,scheduleid) values('$custname','$smobile','$stime','$content','$website','$yyno')";
$result = mysql_query($sql,$con);
/*
if($result)
{
echo "insert success!";
}
else
{
echo "insert fail!";
}*/

//echo mysql_result($result,0);
mysql_close($con);
function sendSMS($username,$password,$mobile,$content,$apikey)
{
$url = 'http://m.5c.com.cn/api/send/?';
$data = array
(
'username'=>$username, //用户账号
'password'=>$password, //密码
'mobile'=>$mobile, //号码
'content'=>$content, //内容
'apikey'=>$apikey, //apikey
);
$result= curlSMS($url,$data); //POST方式提交
return $result;
}

function curlSMS($url,$post_fields=array()){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600); //60秒
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_REFERER,'http://www.czmebel.com');
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_fields);
$data = curl_exec($ch);
curl_close($ch);
$res = explode("\r\n\r\n",$data);
return $res[2];
}