No data being added to SQL database

Status
Not open for further replies.

techiegi

New Member
Messages
29
Reaction score
0
Points
1
echoing errors tells me success so that is not it.
Index.php
PHP:
<?php
session_start();

?>
<!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" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Custom Version</title>
</head>
<body>
<form action="add.php" method="post">
    <p>
        <label for="project_number">Project Number:</label>
        <input type="number" name="project_number" id="project_number">
    </p>
    <p>
        <label for="project_name">Project Name:</label>
        <input type="text" name="project_name" id="project_name">
    </p>
    <p>
        <label for="project_desc">Project Description:</label>
        <input type="text" name="project_desc" id="project_desc">
    </p>
    <p>
        <label for="project_start">Project Start Date:</label>
        <input type="date" name="project_start" id="project_start">
    </p>
    <p>
        <label for="project_end">Project End Date:</label>
        <input type="date" name="project_end" id="project_end">
    </p>
    <input type="submit" value="Submit">
</form>
</body>
</html>

add.php
PHP:
<?php
session_start();
include_once("header.php");
?>
<html>
<body>
<?php
mysqli_select_db($con,$DATABASE);

$sql="INSERT INTO project (project_number,project_name,project_desc,project_start,project_end)VALUES('$_POST[project_number]','$_POST[project_name]','$_POST[project_desc]','$_POST[project_start]','$_POST[project_end]')";
echo $sql;
if($con = new mysqli($SERVER, $USER, $PASS, $DATABASE)){ echo "success"; }else{ echo "error: " . mysqli_error($con); }
mysqli_close($con);
?>
</body>
</html>

header.php
PHP:
<?php
$SERVER = 'localhost';
$USER = 'techiegi_user';
$PASS = 'pass';
$DATABASE = 'techiegi_database';

error_reporting(E_ALL); ini_set('display_errors', 1); 
// Create connection
$con = new mysqli($SERVER, $USER, $PASS);

// Check connection
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}
echo "Connected successfully";
?>
page is at php.techiegiveways.com
 
Status
Not open for further replies.
Top