0

我有一个问题,我有一个页面和一个表单,我将其定向到自身以将数据编辑到数据库。我需要一种方法来使用表单并使用 action=editcinemas.php?cinema_id=THE ID OF CINEMA 重定向自身

 <html>
<body>
<form name="form3" method="post" action="editcinemas.php"> //MY PROBLEM IS HERE I GUESS
    <td>
        <table>
        <?php
require('../classes/cinema_class.php');
$cinema=new cinema($_GET["cinema_id"]);

$cinemas = $cinema->get_all_cinemas();

foreach ($cinemas as $movie)
{
    $cinema_id = $movie['cinema_id'];
    $cinema_name = $movie['cinema_name'];
    $cinema_location = $movie['cinema_location'];

}
    echo "<input name='cinemaid' type='hidden' id='cinemaid' value=" . $cinema_id . '><br/>';
    echo "Cinema Name :";
    echo "<input name='cinemaname' type='text' id='cinemaname' value=" . $cinema_name . '><br/>';
    echo "Cinema Location :";
    echo "<input name='cinemalocation' type='text' id='cinemalocation' value=" . $cinema_location . '><br/>';
?>
</table>
<input type="submit" name="Edit" value="Edit">      <input type="reset" name="Reset" value="Reset"/><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;">

</form>
</body></html>


<?php
$cinemaid=$_POST['cinemaid'];
$cinemaname=$_POST['cinemaname'];
$cinemalocation=$_POST['cinemalocation'];
if ($_POST) { 
if(empty($cinemaname)){  
echo  "Cinema Name is a must"; }
else{
$update_movie=mysql_query("UPDATE `memoire`.`cinema` 
                        SET `cinema_name`= '$cinemaname', `cinema_location`= '$cinemalocation' 
                        WHERE `cinema_id`='$cinemaid'");
if($update_movie)
{ header("Refresh: 0;url=../listallcinemas.php");}
else
{ echo "error in registration".mysql_error(); }

}
?>
4

1 回答 1

1

只需简单地附加它,如下所示:

<form name="form3" method="post" action="editcinemas.php?cinema_id=<?php echo $_GET["cinema_id"]; ?>">
于 2013-05-04T14:56:06.443 回答