标题:html应用PHP变量,激活码部分出错。
只看楼主
张春萧
Rank: 1
等 级:新手上路
帖 子:9
专家分:1
注 册:2010-4-21
结帖率:100%
 问题点数:0 回复次数:1 
html应用PHP变量,激活码部分出错。
程序代码:
<?php

 session_start();
//链接数据库
    $con=@mysql_connect("localhost","byr","123456")
        or die("fail to connect the DB server");
    $con_db=@mysql_select_db("byr",$con)
        or die("fail to connect the DB");
    mysql_query("set names utf-8"); //解决中文乱码问题
//获取信息
$gender = $_POST['gender'];
$ocupation = $_POST['ocupation'];
$year = $_POST['year'];
$month= $_POST['month'];
$day = $_POST['day'];
$province = $_POST['province'];
$city = $_POST['city'];
$salary = $_POST['salary'];
$name=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$mail=$_POST['email'];
//如果用户名存在,提示用户名不可用
//init_db();
$sql="select*from viv_db where username = '$name'";
$ret=mysql_query($sql);
if($ret > 0 or $name == '')
{     echo "<script>alert('用户名已存在');</script>";
      die();
}
if($password != $password2 or $password == '')
{     echo "<script>alert('两次密码输入不一致');</script>";
      die();
}
//验证密码
//合格就加入数据库保
$query = mysql_query("INSERT INTO `viv_db` (`Password`, `nickname`, `birthday`,`gender`, `address`, `salarypm`, `ocupation`, `email`) VALUES ('$password', '$name', '$year-$month-$day', '$gender', '$province-$city', '$salary', '$ocupation', '$mail')");
if($query){
    $_SESSION['username'] = $name;
   $to = $mail;
   $subject = "激活码";
   $url = 'http://211.68.71.187/var/www/html/byr/viv_linux/amu/active.php';
   $url .='?name='.trim($name).'&pwd='.md5(trim($password));
   //echo $url;
  // echo $to;
   $message = "
   <html>
   <head>
   <titile>激活码</title>
   </head>
   <body>
   <p> 这是你的激活码,点击激活码,激活用户</p>
   <p>
   /////////////////////////////////////////////////////////////////////////////////////
   <a href="'.$url.'",target ="_blank">'.$url.'</a></p>
   错误:Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in ....
   ////////////////////////////////////////////////////////////////////////////////////
   </body>
   </html>
";
  $header = "MIME-Version:1.0\r\n";
  $header .= "Content-type: text/html; charset=iso-8859-1\r\n";
   mail($to , $subject , $message , $header);
?>
  <script language='javascript'>
     alert('注册成功!');
     window.location.href='index.php';
  </script>
<?php
}
else{
    echo "<script>alert('注册失败!');</script>";}
?>


[ 本帖最后由 张春萧 于 2011-8-8 00:53 编辑 ]
搜索更多相关主题的帖子: html php localhost server 激活码 
2011-08-08 00:40
张春萧
Rank: 1
等 级:新手上路
帖 子:9
专家分:1
注 册:2010-4-21
得分:0 
顶,求解答
2011-08-08 14:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-347030-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.101481 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved