Home >php教程 >PHP源码 >php登录代码

php登录代码

PHP中文网
PHP中文网Original
2016-05-25 17:06:431226browse

php代码

<?
error_reporting(0);
$mysql_servername = "localhost"; //主机地址
$mysql_username = "root"; //数据库用户名
$mysql_password ="a1234567"; //数据库密码
$mysql_database ="zhuang"; //数据库
mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database); 
$name=$_POST[&#39;name&#39;];
$passowrd=$_POST[&#39;password&#39;];

if ($name && $passowrd){
 $sql = "SELECT * FROM login WHERE name = &#39;$name&#39; and pass=&#39;$passowrd&#39;";
 $res = mysql_query($sql);
 $rows=mysql_num_rows($res);
  if($rows){
   header("refresh:0;url=a.htm");//跳转页面,注意路径
   exit;
 }
 echo "<script language=javascript>alert(&#39;用户名密码错误&#39;);history.back();</script>";
}else {
 echo "<script language=javascript>alert(&#39;用户名密码不能为空&#39;);history.back();</script>";
}

?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn