贵人礼-情人节微信送玫瑰小游戏总结

http://1.rose111.applinzi.com/guirenli(建议微信手机端访问)
责任:
新浪云数据库建表,查询
1.通过PHP获取用户的ip地址,处理form表单提交的数据
2.mysql数据库插入,查询并返回指定用户
3.用户关注公众号后,公众号推送游戏链接
process_form.php

<?php
//领取一束
$hostname = SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT;
$dbuser = SAE_MYSQL_USER;
$dbpass = SAE_MYSQL_PASS;
$dbname = SAE_MYSQL_DB;
$link = mysql_connect($hostname, $dbuser, $dbpass);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully<br/>';
//select db
mysql_select_db($dbname, $link) or die ('Can\'t use dbname : ' . mysql_error());
//echo 'Select db '.$dbname.' successfully';
mysql_close($link);


 // create short variable names
  $user_name=$_POST['user_name'];
  $phone=$_POST['phone'];
  $address=$_POST['address'];
  $postcode=$_POST['postcode'];

  if (!$user_name || !$phone || !$address ) {
     echo "You have not entered all the required details.<br />"
          ."Please go back and try again.";
     exit;
  }

  if (!get_magic_quotes_gpc()) {
    $user_name = addslashes($user_name);
    $phone = addslashes($phone);
    $address = addslashes($address);
    $postcode = doubleval($postcode);
  }
  $mysql = new SaeMysql();
 //@ $db = new SaeMysql("SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,app_meltykiss");
//@ $db = new mysqli('localhost', 'root', '', 'books');

 // if (mysqli_connect_errno()) {
  //   echo "Error: Could not connect to database.  Please try again later.";
   //  exit;
  //}

  $sql= "insert into user (user_name,phone,address,postcode) values
            ('".$user_name."', '".$phone."', '".$address."', '".$postcode."')";
  $result = $mysql->runSql($sql);
  $mysql->closeDb();
   if ($result) {
       echo "<img src=\"images/submit_success.png\" alt=\"success\" style=\"position: absolute; top:23.67%;  left:2%; 
    width: 100%;height:80% \"/>";

 } else {

 echo "<table class=\"table table-striped\"><tr>
  <td class=\"info\">An error has occurred. The item can not be repeated.</td></tr></table>";
  }



?>

订阅关注微信号:推送游戏链接

<html>
<script src="js/jquery-2.1.4.js" type="text/javascript"></script>
<script src="js/app.js"></script>
<script type="text/javascript">   
function test() {     
    window.totalAmount = parseInt(window.totalAmount) + 500 ;     
    window.View.saveStorage(5,parseInt(window.totalAmount));
    window.countTotalAmount.text(parseInt(window.totalAmount));

}   
</script>  

<?php

/*** wechat php test */

//define your token

define("TOKEN", "weixin");

$wechatObj = new wechatCallbackapiTest();

if (isset($_GET['echostr'])) {
    $wechatObj->valid();
}else{
    $wechatObj->responseMsg();
}

class wechatCallbackapiTest
{
    public function valid()
    {
        $echoStr = $_GET["echostr"];
        if($this->checkSignature()){
            ob_clean();
            echo $echoStr;
            exit;
        }
    }

    private function checkSignature()
    {

        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];

        $token = TOKEN;
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );

        if( $tmpStr == $signature ){
            return true;
        }else{
            return false;
        }
    }

    public function responseMsg()
    {
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];

        if (!empty($postStr)){
            $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
            $fromUsername = $postObj->FromUserName;
            $toUsername = $postObj->ToUserName;
            $keyword = trim($postObj->Content);
            $time = time();
            $textTpl = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[%s]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        <FuncFlag>0</FuncFlag>
                        </xml>";
            if($keyword == "?" || $keyword == "?")
            {
                $msgType = "text";
                $contentStr = date("Y-m-d H:i:s",time());
                $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                echo $resultStr;
            }
        }else{
            echo "";
            exit;
        }
    }
}
?>


获取用户ip

<html>
<body>
<?php



  @ $db = new SaeMysql("SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,app_rose111");

  if (mysqli_connect_errno()) {
     echo 'Error: Could not connect to database.  Please try again later.';
     exit;
  }
  $value=8;
    $sql = "select * from ordersip where orderid like '%".$value."%'";
 //$sql="select * from table1 where field1 like ’%value1%’ ";
  //$sql = "select * from  ordersip limit 6,1 ";

  $result = $db->getData($sql);
  if($result){
    ?>
    <br/>
    <br/>
    <?php 

foreach($result as $small){
    $ip = $answer.$small['ip']; //获取符合搜索要求的记录的字段
    $orderid = $answer.$small['orderid'];


echo $ip;
echo"<br/>";
echo $orderid;
}
}
?>

<script>

var b=<?php echo $orderid; ?>

alert (b);
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值