My issue is after submitting the form element in a php
page, the page does not refresh. Here is my code.
<?php
session_start();
include('db.php');
include('pages.php');
?>
form element
<form action = "<?php echo $_SERVER['PHP_SELF'];?>" method = "POST">
<table style="width:70%">
<tr>
<td width="10%">First Name</td>
<td width="20%"><input style="border-radius: 4px; border: 2px solid gray; height: 20px; width: 180px;" type="text" name="fname" value="<?php echo $f_name;?>"></td>
</tr>
<input style="border-radius: 5px; width: 100px; height: 25px;" type="submit" name="account_update" value="Update"/></td>
</table>
</form>
if(isset($_POST['account_update']) && $_POST['account_update'] == 'Update'){
$fname_edit = $_POST['fname'];
$sql = $db->prepare("SELECT * from table where email = ?");
$sql->bind_param("s",$email);
$sql->execute();
$sql = $sql->get_result();
if(($getRowCount = $sql->num_rows) == 1){
$updateQuery = $db->prepare("UPDATE info set first_name=? where email = ?");
$updateQuery->bind_param("ss",$fname_edit,$email);
$updateQuery->execute();
}
}
?>
So clicking on update, inserts the data in the tale, but it only shows up on the page when I refresh it for a second time.
Also. pages.php
is another page being fetched by including. My current page gets refreshed fine if I remove the include('pages.php')
, but not with it. Any suggestions on how to get this thing out this would be of great help.