I am working my assignment and i can't get my update to work with my database. Here is my form that holds the data.
<form name="edit" method="post" action="process/editRecord.php">
<p class="indent">
<label for="projectName">Edit Project Name</label>
<input type="text" name="projectName" id="projectName" value="<?php echo $projectName; ?>">
</p>
<p class="indent">
<label for="projectSoftware">Edit Project Software</label>
<input type="text" name="projectSoftware" id="projectSoftware" value="<?php echo $projectSoftware; ?>" >
</p>
<p class="indent">
<label for="projectDescription">Edit Project Description</label>
<textarea name="projectDescription" id="projectDescription" cols="150" rows="10" ><?php echo $projectDescription; ?></textarea>
</p>
<p class="indent">
<label for="projectImage">Edit Project Image</label>
<input type="text" name="projectImage" id="projectImage" value="<?php echo $projectImage; ?>" >
</p>
<p class="indent">
<label for="projectInformation">Edit Project Information</label>
<textarea name="projectInformation" id="projectInformation" cols="400" rows="10" ><?php echo $projectInformation; ?></textarea>
</p>
<p>
<input type="submit" name="button" id="button" value="Update">
</p>
</form>
And then is the process.
<?php
ini_set('display_errors', 1);
require('../../includes/conn.inc.php');
require('../../includes/functions.inc.php');
// sanitize user variables
$sprojectName = safeString($_POST['projectName']);
$sprojectSoftware = safeString($_POST['projectSoftware']);
$sprojectDescription = safeString($_POST['projectDescription']);
$sprojectImage = safeString($_POST['projectImage']);
$sprojectInformation = safeString($_POST['projectInformation']);
$sprojectID = safeInt($_POST['projectID']);
// prepare SQL
$stmt = $mysqli->prepare("UPDATE projects SET projectName =?, projectSoftware =?, projectDescription=?, projectImage =?, projectInformation =? WHERE projectID = ?");
$stmt->bind_param('sssssi', $sprojectName, $sprojectSoftware, $sprojectDescription, $sprojectImage, $sprojectInformation, $sprojectID);
$stmt->execute();
$stmt->close();
header("Location: ../../php/projects.php");
// redirect browser
exit; // make sure no other code executed
?>
I get no errors when using this and it doesn't update my database but goes back to relevant projects page.