我有2页, add.php 页面和主要页面。
单击主页面中添加的按钮后,主页面将成功显示add.php页面。
这是我为主页试过的代码:
if(isset($_POST['add']))
{
include('add.php');
}
这是我为 edit.php
尝试过的代码 <html>
<head>
<title>EDIT</title>
</head>
<body>
<form method='POST' action="o.php">
<input type='text' name='username' value='<?php
$textarea1 = "";
$pos="";
if(isset($_SESSION['use'])){
$textarea1 = $_SESSION['use'];
}
echo $textarea1;
?>'>
<input type='hidden' name='fakename' value='<?php
$textarea1 = "";
if(isset($_SESSION['use'])){
$textarea1 = $_SESSION['use'];
}
echo $textarea1;
?>'>
<input type='password' name='passwordz' value='<?php
$textarea1 = "";
if(isset($_SESSION['pak'])){
$textarea1 = $_SESSION['pak'];
}
echo $textarea1;
?>' >
<input type='submit' name='editit' value='edit'>
</form>
</body>
</html>
<?php
if(!empty($_POST['editit']))
{
$truename=$_POST['fakename'];
$username=$_POST['username'];
$password=$_POST['passwordz'];
mysql_connect("localhost", "root", "");
mysql_select_db("sad");
$sql = mysql_query("UPDATE users SET username = '$username', password='$password' where username='$truename'");
echo'CONGRATULATIONS YOU HAVE SUCCESFULLY EDIT YOUR ACCOUNT';
}
?>
问题出在此处,在 add.php 页面中显示 ,但不会执行仅刷新页面的操作并且什么都不做。我做错了什么?
答案 0 :(得分:1)
<?php
session_start();
if( isset($_POST['add']) || isset($_SESSION['USE_ADD']) )
{
$_SESSION['USE_ADD'] = TRUE;
include('add.php');
}
?>