前段代码:

<form action="__CONTROLLER__/zhuce" method="post">
	<div class="input-group">
		<span class="input-group-addon">邮箱号码:</span>
		<input type="text" name="youx" class="form-control" placeholder="请输入邮箱号码">
	</div>
	<br>
	<div class="input-group" style="width: 350px;height:34px;float:left ;">
		<span class="input-group-addon">邮箱验证码:</span>
		<input id="youxiang" name="youxy" type="password" class="form-control" placeholder="请输入邮箱验证码">
	</div>
	<div style="float: right;width: 100px;height:34px;"><input id="fasong" type="button" class="btn btn-default" value="发送" /></div>
	<br>
	<div style="clear: both;height: 20px;"></div>
	<div class="input-group">
		<span class="input-group-addon">密码:</span>
		<input type="text" name="mima" class="form-control" placeholder="请输入密码">
	</div>
	<br>

	<div class="input-group">
		<span class="input-group-addon">姓名:</span>
		<input type="text" name="xingming" class="form-control" placeholder="请输入姓名">
	</div>
	<br>
	<div class="input-group">
		<span class="input-group-addon">电话号码:</span>
		<input type="text" name="tel" class="form-control" placeholder="请输入电话号码">
	</div>
	<br>
	<div class="input-group">
		<span class="input-group-addon">身份证号码:</span>
		<input type="text" name="id" class="form-control" placeholder="请输入身份证号码">
	</div>
	<br>
	<div style="width: 300px;height:34px;float:left ;" class="input-group">
		<span class="input-group-addon">验证码:</span>
		<input type="text" name="yzm1" class="form-control" placeholder="请输入验证码">
	</div>
	<div style="float: right;"><img id="img1" src="__CONTROLLER__/yzm1" onclick="huan1()" width="150px" /></div>
	<br>
</form>

  

后端代码:

public function yanzheng() {
		$yx = $_POST["yx"];
		$yx = "992028296@qq.com";
		$showapi_appid = '50481';
		//替换此值,在官网的"我的应用"中找到相关值
		$showapi_secret = '739ed531347f44c086c63afa64a34295';
		//替换此值,在官网的"我的应用"中找到相关值
		$paramArr = array('showapi_appid' => $showapi_appid, 'toEmail' => "$yx", 'title' => "验证码", 'checkcode' => ""
		//添加其他参数
		);

		//创建参数(包括签名的处理)
		function createParam($paramArr, $showapi_secret) {
			$paraStr = "";
			$signStr = "";
			ksort($paramArr);
			foreach ($paramArr as $key => $val) {
				if ($key != '' && $val != '') {
					$signStr .= $key . $val;
					$paraStr .= $key . '=' . urlencode($val) . '&';
				}
			}
			$signStr .= $showapi_secret;
			//排好序的参数加上secret,进行md5
			$sign = strtolower(md5($signStr));
			$paraStr .= 'showapi_sign=' . $sign;
			//将md5后的值作为参数,便于服务器的效验
			return $paraStr;
		}

		$param = createParam($paramArr, $showapi_secret);
		$url = 'http://route.showapi.com/932-4?' . $param;
		$result = file_get_contents($url);
		$result = json_decode($result);
		$code = $result -> showapi_res_body -> code;
		session("yx", $code);
	}

  

posted on 2017-11-30 15:38  唯懿  阅读(4373)  评论(0编辑  收藏  举报