I have a basic question. I have a simple table (1 field only -nama) and 1 simple page using php. I can insert data into table "userad". But when I add several fields such as id, name2, color2, and hobby2, mysql frequently returns empty result. The id is interger NOT NULL, and also not auto incremented.I'm not sure what's the problem. I've already browse the Internet for solutions but could not find and understand the problem to solve it. Please help...tq..
Below is the PHP script for single data-mysql able to display data.
<?php
// Start the session.
session_start();
require 'connect-test.php';
if(isset($_POST['nama']))
{ $nama = $_POST['nama'];
$stmt = $conn->prepare("INSERT INTO userad (nama) VALUES (?)");
$stmt->bind_param("s", $nama);
$stmt->execute();
$stmt->close();
$conn->close(); }
?>
<html>
<head> </head>
<body>
<form name="form2" method="post" action="testdelete2.php">
<p>nama :
<input type="text" name="nama" id="nama">
</p>
<p>
<input type="submit" name="button" id="button" value="Submit">
</p>
</form>
</body>
</html>
Below is the php script for multiple data- mysql keeps returning empty result (error)
<?php
// Start the session.
session_start();
require 'connect-test.php';
if(isset($_POST['submit']))
{
$id = $_POST['id'];
$name2 = $_POST['name2'];
$color2 = $_POST['color2'];
$hobby2 = $_POST['hobby2'];
$stmt = $conn->prepare("INSERT INTO userad (id,name2,color2,hobby2) VALUES (?,?,?,?)");
$stmt->bind_param("isss",$id,$name2,$color2,$hobby2);
$stmt->execute();
$stmt->close();
$conn->close();}
<html>
<head> </head>
<body>
<form name="form2" method="post" action="testdelete2.php">
<p>id:
<input type="text" name="id" id="id">
</p>
<p>name2:
<input type="text" name="name2" id="name2">
</p>
<p>color2:
<input type="text" name="color2" id="color2">
</p>
<p>hobby2:
<input type="text" name="hobby2" id="hobby2">
</p>
<p>
<input type="submit" name="button" id="button" value="Submit">
</p>
</form>
</body>
</html>