所以我有一个HTML页面(上面有一些PHP加载了一个functions.PHP和一个header.PHP页面),在post时,它成功地执行了一个位于functions.PHP页面上的函数。我试图在post之后返回一个值,该值将指示成功或错误,但我需要它显示在某个div中,否则我将只让functions.php页面回显结果。我不想使用ajax,但如果必须的话,我会使用的。
第1页(html页):
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)
第2页(功能页):
// 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;
}