So I have an HTML page (has some PHP on it loading a functions.php and a header.php page) and upon post, it executes a function that is located on functions.php page successfully. I am trying to return a value back to the html page after post that would indicate a success or error but I need it to be displayed within a certain div, otherwise I would just let the functions.php page echo the result. I'd prefer not to use ajax but if I have to then I will.
EDIT: Sorry, forgot to explain what is happening. Duh. So after post, it shows both the success and the error message, as if both if statements are being returned at the same time. It will show "Updated Successfully!" AND "Error!" at the same time.
Page 1 (html page):
include('session.php');
include('header.php'); // Includes Header Script
include('functions.php');
$cus_details=getAddress($login_id);
foreach($cus_details as $cus_details) {
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$result = updateAddress($login_id, $_POST);
}
?>
<body style="background-image: url('Scripts/background.png'); -moz-background-size: cover; -webkit-background-size: cover; -o-background-size: cover; background-size: cover;">
<center><div id="signup">
<div class="container1">
<form class="addressForm" action="" method="post">
<?php if ( $result == true ) { ?>
<br><br><center><span4>Updated Successfully!</span4></center>
<? } else if ( $result == false ) { ?>
<br><br><center><span4>Error!</span4></center>
<?php } ?>
..... (more html)
Page 2 (functions page):
// Update Customer Address
function updateAddress($login_id, $data) {
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysqli_connect("localhost", "root", "");
// Selecting Database
$db = mysqli_select_db($connection,"db_name");
// SQL Query To Fetch Complete Information Of User
$ses_sql=("update rma_customer_address set cus_address_1='".$data['address1']."' WHERE cus_id='$login_id' AND cus_address_type=0");
if (mysqli_query($connection, $ses_sql)) {
$success = true;
} else {
$success = false;
}
mysqli_close($connection);
return $success;
}