我的数据库php代码在XAMPPV3.2.2上不起作用?

mi7gmzs6  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(460)

这个问题在这里已经有答案了

为什么我不应该在php中使用mysql函数(12个答案)
两年前关门了。
php mysql\u connect(“localhost”,“root”,“”)或die(mysql\u error());mysql\u select\u db(“shehan”)或die(mysql\u error());

if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $date = date('Y-m-d');
    $b_t = $_POST['b_t'];
    $country = $_POST['country'];
    $company = $_POST['company'];
    $message = $_POST['message'];
    $to = "mo19867@eastwest.edu";
    $message1 = "
                     $name:
    Thanks for contacting.we recieve Your Message and will contact you asap.

    Country: $country
    Company: $company
    Phone No: $phone
    Email ID: $email                                              
    Message: $message                                              
    Paid Date: $date";

    mysql_query("insert into contactus(name,email,phone,business,country,company,message) values('$name','$email','$phone','$b_t','$country','$company','$message')")or die(mysql_error());
    mail("$to","www.shehangems.com",$message1);

        echo "<script>alert('You have successfully submitted your data.');
    window.location.href='contact.html'
    </script>";
tvz2xvvm

tvz2xvvm1#

你用的是古老的 mysql_ 功能。这些不再是php的一部分。
我建议你换成pdo。
在这里看到一个出色的入门pdohttps://phpdelusions.net/pdo
当然,还有医生http://php.net/manual/en/class.pdo.php
有些人会建议你改用 mysqli . 先看看这个再考虑那个。https://phpdelusions.net/pdo/mysqli_comparison

相关问题