PHP值未显示

时间:2019-03-13 15:34:05

标签: php html mysql

我正在做一些小练习,但我仍然是PHP的初学者。我设法在数据库中获取第一个表的数据,但在插入后的第二个表中,我无法在phpMyadmin中获取任何数据。我曾尝试过搜索互联网,但是大多数响应是关于将mysql更改为mysqli的。即使这样做,也没有区别。

<?php
// Establishes a connection with the Server (localhost).
$host = "localhost";
$user = "root";     // User Name
$pass = ""; // Passward
$con = mysqli_connect($host, $user, $pass);

if(!$con)
{
    echo 'Not Connected To Server';
}

if(!mysqli_select_db($con,'parttwo_db'))
{
    echo 'Database Not Selected';
}

$Religion = $_POST['Religion'];
$Race = $_POST['Race'];

$sql = "INSERT INTO parttwo_tb (Religion,Race) VALUES ('$Religion', '$Race')";

$result = mysql_query($sql);

if($result)
{
    echo "Succesful";
}

else{
    echo "Something went wrong: " .mysql_error();
}

header("location:form3.html");

The phpmyAdmin table for the parttwo_db

这是html文件。

<!DOCTYPE html>
  <html>
  <head>
<title>Second Form</title>
 <style type="text/css">
    label {
        width: 200px;
        display: inline-block;
    }
    </style>
 </head>
<body>

<p>Student Registration Form</p>
<form action="secondpart.php" method="post">

    <p><label>Religion <input type="text" name="Religion"></label></p>
    <p><label>Race: <input type="text" name="Race"></label>
    </p>

    <p>
        <input type="submit" value="Insert">
        <input type="reset" value="Clear">      
    </p>

</form>

0 个答案:

没有答案