I'm a beginner and i have a few problems with my codes.

我是初学者,我的代码有一些问题。

Every things seems to be ok with my codes because it doesn't give me any errors, but after saving, i don't get the data reflected in my database.

我的代码似乎一切正常,因为它没有给我任何错误,但保存后,我没有得到数据反映在我的数据库中。

Here is the code:

这是代码:

<?php 
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "election";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}


$sqli = "INSERT INTO `election`.`registration` (`Reg_Num`, `Full_Name`, `Level`, `Gender`) VALUES ('$_POST[Reg_Num]', '$_POST[Full_Name]', '$_POST[Level]', '$_POST[Gender]');";
?>  


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form</title>
</head>
<body>
<title>Form Submitted</title>
<p></p>
<p>Thanks for Registering</p>
<p></p>
<a href="vote.php">Register another student</a><br />
</body>
</html>

Please help!

3 个解决方案

#1


1

You need to actually execute the INSERT statement, e.g.

您需要实际执行INSERT语句,例如

$sqli = "INSERT INTO `election`.`registration` (`Reg_Num`, `Full_Name`, `Level`, `Gender`) VALUES ('$_POST[Reg_Num]', '$_POST[Full_Name]', '$_POST[Level]', '$_POST[Gender]');";
if ($conn->query($sqli) === TRUE) {
    echo "insert succeeded";
} else {
    echo "Error: " . $conn->error;
}

更多相关文章

  1. php二维码/26行代码制作php二维码phpqrcode加grafika水印
  2. php分页代码的问题,显示了两个当前页码,求大神解答
  3. PHP开发微信支付代码及支付通知处理
  4. 几个有用的php字符串过滤,转换函数代码
  5. mysqli类使用预处理语句不返回任何数据
  6. 在Web Page中包含PHP代码
  7. php mail函数一段好的代码
  8. 用于上传多个文件的PHP代码
  9. (phpQuery)对网站产品信息采集代码的优化

随机推荐

  1. java运行时数据区域
  2. java集合系列(6)Vector
  3. synchronized的实现原理和应用
  4. java集合系列(3)ArrayList
  5. 设计模式之装饰模式
  6. 学习资源大汇总
  7. 设计模式之享元模式
  8. jvm系列(5)性能监控工具
  9. java集合系列(4)fail-fast机制(面试常问)
  10. 设计模式之原型模式