Been over this for the past hour and can't figure out what might be causing the error. Previously I populated the database via a command line in mysql. It worked fine. But I want to add a GUI element for the ordinary user who doesn't understand linux/ line commands etc.
So I decided to add a html form which would post to php. I've done it before on a different form so can't figure out what might be causing the error.
this is the html form:
<form action="insertjob.php" method="post" class="basic-grey">
<label>Job Title:</label><input type="text" name="job_title" id="job_title"/><br>
<label>Job Description:</label><input type="text" name="job_description" id="job_description"/><br>
<label>Job Location:</label><input type="text" name="job_location" id="job_location"/><br>
<label>Job Category:</label><input type="text" name="job_category" id="job_category"/><br>
<input type="submit" name=submit value="Submit"/>
</form>
then when the user presses submit...it leads to...
insertjob.php
<?php
$user = "root";
$password = "*****";
$host = "********";
$dbase = "jobslist";
$table = "jobs_list";
$job_title= $_POST['jobtitle'];
$job_description= $_POST['jobdescription'];
$job_location= $_POST['joblocation'];
$job_category= $_POST['jobcategory'];
$dbc= mysqli_connect($host,$user,$password,$dbase)
or die("Unable to select database");
$query= "INSERT INTO $table ". "VALUES ('$job_title', '$job_description', '$job_location', '$job_category')";
mysqli_query ($dbc, $query)
or die ("Error querying database");
//header('Location: thankyou.html');
mysqli_close($dbc);
?>
It's not a database problem as I've checked. I don't think it's a connection problem either as I've checked the developer tools and there's no errors. I suspect it might be the variables?