我是初学者,我正在尝试将提交的表单的值插入数据库。此外,我试图从数据库中检索一个值,并使用mysqli_fetch_row()在我的页面上显示它。但是,页面不返回任何值。请帮忙。
<?php
<!--php start-->
include('mysqlconnect.php');
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$category = $_POST['category'];
$cost = $_POST['cost'];
$description = $_POST['message'];
if((isset($_POST['submit'])))
{
$name_g = $GLOBALS['name'];
$phone_g = $GLOBALS['phone'];
$email_g = $GLOBALS['email'];
$category_g = $GLOBALS['category'];
$cost_g = $GLOBALS['cost'];
$description_g = $GLOBALS['description'];
$query = "INSERT INTO data (name,phone,email,category,cost,description) VALUES ('$name_g','$phone_g','$email_g','$category_g','$cost_g','$description_g')";
(mysqli_query($conn,$query)) or die("Cannot submit, please try again");
}
<!--further details-->
$key= "SELECT No from data where name =' ". $name. " '";
$result = mysqli_query($conn,"SELECT * from data where name =' ". $name. " '");
$row = mysqli_fetch_row($result);
echo $row[0];
?>
<!--end of php-->