I have this form:
<div class="col-md-6">
<h4>Update Contact Details</h4>
<form action="" method="post" name="contact" id="contact">
<div class="form-group">
<label>*Address:</label>
<input type="text" class="form-control" id="address_line_1" name="address_line_1" value="<? echo $address_line_1; ?>" placeholder="Address Line 1..." required="required">
<input type="text" class="form-control" id="address_line_2" name="address_line_2" value="<? echo $address_line_2; ?>" placeholder="Address Line 2...">
<label>*Postcode:</label>
<input type="text" class="form-control" id="postcode" name="postcode" value="<? echo $postcode; ?>" placeholder="Postcode" required="required">
</div>
<div class="form-group">
<label>*Phone Number:</label>
<input type="number" class="form-control" id="contact_number" name="contact_number" value="<? echo $contact_number; ?>" placeholder="Phone Number" required="required">
</div>
<div class="form-group">
<input type="hidden" class="form-control" id="userid" name="userid" value="<? echo $userid; ?>">
<button type="submit" id="contact" name="contact" class="btn btn-primary btn-sm">Save Details</button>
</div>
</div>
Which runs to this script:
if(isset($_POST['contact'])){
$address_line_1 = str_replace("'","\\'",$_POST['address_line_1']);
$address_line_2 = str_replace("'","\\'",$_POST['address_line_2']);
$postcode = str_replace("'","\\'",$_POST['postcode']);
$contact_number = $_POST['contact_number'];
$uid = $_POST['userid'];
mysqli_query($conn, "UPDATE ap_users SET address_line_1 = '$address_line_1', address_line_2 = '$address_line_2', postcode = '$postcode', $contact_number = '$contact_number' WHERE user_id = '$uid'");
}
Very basic, I know - when I send the form, the variables which are echoed on the page such as echo $address_line_1
all change to the new results, although when I reload the page, they return to the old results. It appears that the MySQL database isn't being updated when I send the form and I'm not too sure why?