php开发API接口的代码案例
[php] view plain copy print?<?php require
'conn.php';
header('Content-Type:text/html;charset=utf-8'); $action = $_GET['action']; switch ($action) { //注册会员case"adduserinfo"; $username =
lib_replace_end_tag(trim($_GET['username'])); $password2 =
lib_replace_end_tag(trim($_GET['userpassword'])); $password = md5("$password2" . ALL_PS);
$email = lib_replace_end_tag(trim($_GET['email']));
if ($username == '' || $password2 == '' || $password == '') { $res = urlencode("参数有误");
exit(json_encode($res)); //有空信息}
$sql = "select username from `member` where
username='$username'"; $query =
mysql_query($sql, $conn); $count =
mysql_num_rows($query); if ($count > 0) { exit(json_encode(1)); //返回1表示注册失败} else { $addsql = "insert into `member` (username,password,email) values