如何连接数据库?

时间:2019-05-12 10:56:45

标签: php

当我单击“注册”时,将显示此错误

  

致命错误:未捕获错误:调用未定义函数   D:\ server \ htdocs \ Crime-Analyse \ registration.php中的mysql_connect():5   堆栈跟踪:抛出#0 {main}   D:\ server \ htdocs \ Crime-Analyse \ registration.php,第5行

 <?php
if(isset($_POST['s'])){
    $con=mysql_connect('localhost','root','');
    if(!$con)
    {
        die('could not connect: '.mysql_error());
    }
    if($_SERVER["REQUEST_METHOD"]=="POST"){
        $u_name=$_POST['name'];
        $u_id=$_POST['email'];
        $u_pass=$_POST['password'];
        $u_addr=$_POST['adress'];
        $a_no=$_POST['aadhar_number'];
        $gen=$_POST['gender'];
        $mob=$_POST['mobile_number'];
       // $password=md5($u_pass);
       $reg="insert into user values('$u_name','$u_id','$u_pass','$u_addr','$a_no','$gen','$mob')";
        mysql_select_db("crime_portal");
        $res=mysql_query($reg,$con);
        if(!$res)
        {
        $message1 = "User Already Exist";
        echo "<script type='text/javascript'>alert('$message1');</script>";
    }
            else
    {
        $message = "User Registered Successfully";
        echo "<script type='text/javascript'>alert('$message');</script>";
    }
    }
}
?>

0 个答案:

没有答案