以相同的php形式添加和编辑


add and edit in the same form php

我有这个代码:

<?php
////////////////////////////////////////
include "../includes/site_includes.php";//
//////////////////////////////////////
$sql = getallsitesettings();
if ($result = $mysqli->prepare($sql)) 
{
$rekza = 1;
$result->bind_param("i",$rekza);
$result->execute(); 
$result->store_result();
$rowsZ = $result->num_rows;
}
if($rowsZ>0)
{
$row = fetch($result);
}
$siteTitle= $row[0]["site_title"];
$sitePeleText= $row[0]["pele"];
?>
<?php
$act = $mysqli->real_escape_string($_GET["act"]);
if($act=="edit")
{
    $folderid = (int)$_GET["id"];
    $sql2 = getfolderbyId();
    if ($result2 = $mysqli->prepare($sql2)) 
    {
    $result2->bind_param("i",$folderid);
    $result2->execute();    
    $result2->store_result();
    $rowsZ2 = $result2->num_rows;
    }
    if($rowsZ2>0)
    {
    $row2 = fetch($result2);
    }
    for($j=0; $j<$rowsZ2; $j++) 
        {
    $foldername = $row2[$j]["fold_name"];
    $foldpath = $row2[$j]["fold_path"];
    $foldpic = $row2[$j]["fold_pic"];
        }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html dir="rtl">
 <head>
  <title><?=$txt_folders?></title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <link href="<?=$site_url?>/css/styles.css" rel="stylesheet" type="text/css" />
 </head>
    <table align="center" cellspacing="0" cellpadding="0" width="1021">
        <tr>
            <td><?php
            include "../site_header.php";
            ?></td>
        </tr>
        <tr>
            <td style="background-color:#dcdbdb;">
                    <table align="center" cellspacing="0" cellpadding="0" width="1021">
                        <tr>
                            <td>
                                <div class="admintitle">
                                <a href="../main.php" style="color:black; text-decoration:none;"><?=$txt_main_admin?></a> > <?=$txt_folders?>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table align="center" cellspacing="0" cellpadding="0" width="400">
                                    <tr>
                                        <td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folders_name?></td>
                                        <td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_name" value="<?=$foldername?>" /></td>
                                    </tr>
                                    <tr>
                                        <td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folder_path?></td>
                                        <td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_path" value="<?=$foldpath?>" /></td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
            </td>
        </tr>
        <tr>
            <td><?php
            include "../site_footer.php";
            ?></td>
        </tr>
    </table>
 <body>
 </body>
</html>

你能告诉我出了什么问题吗?为什么当act=add输入中value="中的变量未定义?。。。。以及我如何在编辑和添加中定义它们。。。在添加中,我需要它们为空。。。在编辑中效果很好。。。。

可能是…

if($act=="edit" || $act=="add")

:)