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 编辑 ]