I am having a challenge with inserting data from this HTML form into MySQL. No errors are being thrown but the data does not display in the database table. I have other tables in the database that receiving values from other forms with this same approach and it works fine.
Also, I have checked for the possibility of keywords being used as column names by using backticks around each column name in the insert statement, but the problem still doesn't get solved.
I would appreciate your input and support.
HTML Form
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style3.css">
</head>
<body>
<div class="container">
<div id="BigForm1">
<form action="connect3.php" method="POST" id="Form1" name="Form1">
<h3>Profile and Skills Section</h3>
<textarea type="text" placeholder="Profile" id="profile" name="profile" ></textarea>
<input type="text" placeholder="Top Skill 1" id="firstSkill" name="firstSkill" >
<input type="text" placeholder="Top Skill 2" id="secondSkill" name="secondSkill" >
<input type="text" placeholder="Top Skill 3" id="thirdSkill" name="thirdSkill" >
<input type="text" placeholder="Top Skill 4" id="fourthSkill" name="fourthSkill" >
<div class="btn-box">
<button type="submit" id="Next1">Submit</button>
</div>
</form>
</div>
</div>
</body>
</html>
Here's the content of the insertion file
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
//Sppecial User Tracker
$userID2 = $_SESSION["id"];
/*Profile information**/
$profile = $_POST['profile'];
$skill1 = $_POST['firstSkill'];
$skill2 = $_POST['secondSkill'];
$skill3 = $_POST['thirdSkill'];
$skill4 = $_POST['fourthSkill'];
$conn = new mysqli('localhost', 'root', '', 'project');
if($conn->connect_error){
die('Connection Failed : '.$conn->connect_error);
}else{
/*About Information*/
$stmt = $conn->prepare("insert into about2(FullName, Skill1, Skill2, Skill3, Skill4)
values(?, ?, ?, ?, ?)");
$stmt->bind_param("sssss",$about, $skill1, $skill2, $skill3, $skill4);
$stmt->execute();
$stmt->close();
header("location: generated.php");
}
?>