我有通过PHP与MYSQL数据库链接的HTML表单。如果我提交此表单,则值将保存在MYSQL数据库中,但不会加载到表单中。我看到有旧值,所以我必须刷新页面才能看到所需的值。 我希望在表单提交中看到新值。
* 我在ISSET表单提交时将标题(“Location:edit.php?page = zakladni_udaje.php”)(=与表单操作相同)解决了,它工作正常很好,但我不能在提交后打印关于成功或失败的消息。
<?php
ob_start();
session_start();
?>
<form action="edit.php?page=zakladni_udaje.php" method="post">
<?php
$con = mysql_connect("localhost", "mairichovci", "ak41801") or die("Nelze se připojit k MySQL: " . mysql_error());
mysql_select_db("mairichovci") or die("Nelze vybrat databázi: ". mysql_error());
if($_SESSION['id'] > 0){
$profil_pomocny = mysql_query("SELECT * from profil where id=".$_SESSION['id'], $con);
$profil = MySQL_Fetch_Assoc($profil_pomocny);
$or_pomocny = mysql_query("SELECT * from osobaky where id=".$_SESSION['id'], $con);
$or = MySQL_Fetch_Assoc($or_pomocny);
$zobraz_pomocny = mysql_query("SELECT * from zobraz where id=".$_SESSION['id'], $con);
$zobraz = MySQL_Fetch_Assoc($zobraz_pomocny);
$id = $_SESSION['id'];
$fce = $_POST['fce'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$position = $_POST['position'];
$home = $_POST['home'];
$omne = $_POST['omne'];
if( isset ($_POST['uloz'])):
$sql = "UPDATE profil SET
fce = '$fce', email = '$email', tel = $tel, position = '$position', home = '$home', omne = '$omne' WHERE id = '$id'";
if (!mysql_query($sql)):
die('Chyba: ' . mysql_error());
else:
$message = "Údaje byly uloženy";
endif;
mysql_close();
endif;
echo '<div id="message">'.$message.'</div>';
?>
<table style = "margin-top: -1px" align="center" class="tabulka">
<tr>
<td width="40%">Funkce:</td>
<td><input type="text" name="fce" placeholder = "(např. Běžec - 800m, 1500m a delší)" maxlength="35" size="48" value="<?php echo $profil['fce']; ?>" class="vstupy" style="width: 350px"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="uloz" value="Ulož" class="tlacitko2" style="width: 350px; margin-left:4px"></td>
</tr>
</table>
</form>
<?php
}
else{header("Location: prihlas.php");}
ob_end_flush();
?>
我感谢每一个建议。在此先感谢:)