0

我想在表单中使用表单。我有以下代码。

<?php session_start(); 
if(!isset($_SESSION['logged_in'])){
    echo "Sorry! You need to log in to add Information. <a href='login.php'>Login</a>";
} else {
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>iWant | in case you want anything</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">

    <!--link rel="stylesheet/less" href="less/bootstrap.less" type="text/css" /-->
    <!--link rel="stylesheet/less" href="less/responsive.less" type="text/css" /-->
    <!--script src="js/less-1.3.3.min.js"></script-->
    <!--append ‘#!watch’ to the browser URL, then refresh the page. -->

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-responsive.min.css" rel="stylesheet">
    <link href="css/bootstrap-fileupload.min.css" rel="stylesheet">
    <link href="css/bootstrap-fileupload.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="style.css" />
     <script src="jquery.min.js"></script>

  <script src="upload.js"></script>

  <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
  <![endif]-->

  <!-- Fav and touch icons -->
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72-precomposed.png">
  <link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-57-precomposed.png">
  <link rel="shortcut icon" href="img/favicon.png">

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/scripts.js"></script>
    <script type="text/javascript" src="js/bootstrap-fileupload.js"></script>
    <script type="text/javascript" src="js/bootstrap-fileupload.min.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
</head>

<body>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span4">
            <h3>
                iWant | In Case U Want Anything
            </h3>  
        </div>
        <div class="span4">
            <form class="form-search">
                <input type="text" class="input-medium search-query"> <button type="submit" class="btn">Search</button>
            </form>
        </div>
        <div class="span4">
             <a href="login.php" class="btn" type="button">Login</a> <a href="signup.php" class="btn" type="button">Sign Up</a>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="navbar navbar-inverse">
                <div class="navbar-inner">
                    <div class="container-fluid">
                         <a data-target=".navbar-responsive-collapse" data-toggle="collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a> <a href="index.php" class="brand">iWant</a>
                        <div class="nav-collapse collapse navbar-responsive-collapse">
                            <ul class="nav">
                                <li>
                                    <a href="#">Home</a>
                                </li>
                                <li>
                                    <a href="#">About iWant</a>
                                </li>
                                <li>
                                    <a href="#">Contact iWant</a>
                                </li>
                            </ul>
                            <ul class="nav pull-right">
                                <li>
                                    <a href="#">My iWant</a>
                                </li>
                                <li class="divider-vertical">
                                </li>
                                <li class="dropdown">
                                     <a data-toggle="dropdown" class="dropdown-toggle" href="#">Post Adds<strong class="caret"></strong></a>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a href="room.php">Room</a>
                                        </li>
                                        <li>
                                            <a href="#">Hostel</a>
                                        </li>
                                        <li>
                                            <a href="#">Apartment</a>
                                        </li>
                                        <li>
                                            <a href="#">Land</a>
                                        </li>
                                        <li>
                                            <a href="#">House</a>
                                        </li>
                                        <li>
                                            <a href="#">Vehicles</a>
                                        </li>
                                        <li>
                                            <a href="#">Hotels</a>
                                        </li>
                                        <li>
                                            <a href="#">Mobile Phones</a>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </div>

                    </div>
                </div>

            </div>

            <div class="well">

            <form id="Room Details" class="form-horizontal" method="get" action="roomKoDesc.php">
            <?php echo "<input type='hidden' name='clientId' value='".$_SESSION['clientId']."'>"; ?>
            <legend>Post Rooms</legend>
            <div class="control-group">
            <label class="control-label">Contact Number</label>
            <div class="controls">
                <div class="input-prepend">
                    <input type="text" class="input-xlarge" id="contact" name="contact" placeholder="Your Contact">
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Location of Rooms</label>
            <div class="controls">
                <div class="input-prepend">
                    <input type="text" class="input-xlarge" id="location" name="location" placeholder="rooms location">
                </div>
            </div>
        </div>
        <div class="control-group ">
            <label class="control-label">Number of Rooms</label>
            <div class="controls">
                <div class="input-prepend">
                    <input type="text" class="input-xlarge" id="number" name="number" placeholder="no. of rooms">
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Price per Room</label>
            <div class="controls">
                <div class="input-prepend">
                    <input type="text" class="input-xlarge" id="price" name="price" placeholder="price per room">
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Sqare meter</label>
            <div class="controls">          
                  <div class="input-prepend">
                    <input type="text" class="input-xlarge" id="size" name="size" placeholder="Area of rooms">
                </div>

            </div>
        </div>







    <div id ="main">

        <form method="post" enctype="multipart/form-data"  action="upload.php">
            <input type="file" name="images" id="images" multiple />
            <button type="submit" id="btn">Upload Files!</button>
        </form>

    <div id="response"></div>
        <ul id="image-list">

        </ul>
    </div>



        <div class="control-group">
            <label class="control-label">Description</label>
            <div class="controls">
                <div class="input-prepend">
                    <textarea rows="4" cols="50" input type="text" class="input-xlarge" id="description" name="description" placeholder="Description"></textarea>

                </div>
            </div>
        </div>
          <input type="submit" class="btn btn-success" value="Submit" />
      </form>

            </div>

    </div>
</div>
</body>
</html>
<?php } ?>

我的输出看起来像这个例子

但是提交按钮不会指向另一个页面。和上传作品
我怎样才能让提交按钮工作?是否有任何简单的过程来使用嵌套形式。

4

2 回答 2

1
<input type="file" name="images" id="images" multiple />

对整个表格只使用这个,不要使用 2 个单独的表格。此外,当表单提交时,您可以上传文件。

于 2013-08-07T07:57:51.753 回答
0

恩贾尔,

为什么要在一页中使用多个表单。您可以使用一个表单来做同样的事情。只需使用 Javascript 来更改表单的“动作”属性。代码是,

<html>
<head>
<script type="text/javascript" language="javascript">
function changeaction(url)
{
document.frm.action=url;
document.frm.submit();

}
</script>
</head>
<body>
<form name="frm" action="" method="post">
<input type="submit" name="submit" value="submit1" onclick="return  changeaction('upload.php');">
<input type="submit" name="submit" value="submit2" onclick="return changeaction('index.php');">

</form>
</body>
</html>
于 2013-08-08T16:02:05.460 回答