dongyuan7981 2016-03-17 16:05
浏览 14
已采纳

单击[关闭]时,“提交”按钮不执行任何操作

I am trying to insert this form data into the database. However when i press submit nothing happens. I have the following fields in my database; prop_id
prop_title
prop_address
prop_postcode
prop_img
prop_radius
prop_bedrooms
prop_type
prop_price
prop_course
prop_desc
prop_share

<?php
session_start(); 

include ("connect.php");
?>

<!doctype html>
<html>
<head>
    <title>Add a Property</title>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="css/index.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

</head>
<body>

<div class="whole_page_div" style="width:100%; height:935px;">
        <div class="container-fluid" style="margin-top: 15px;>
                <div class="row">
                <div class="col-md-12">
                <div class="logo" style="margin-left: 750px;"><a href="index.php"><img class="logo" src="images/logo.png"/></a></div>
                 <a href="logout.php"> <button type="submit" class="btn btn-primary" name="logout" value="Log out" style="background-color:#337AB7; margin-top: -130px; margin-left: 1600px; ">Log Out</button></a>

                 <a href="landlord_profile.php"> <button type="submit" class="btn btn-primary" name="back" value="My Profile" style="background-color:#337AB7; margin-top: -150px; margin-left: 200px; ">My Profile</button></a>

                </div>


<hr>
    <nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
    <div class="container topnav">


            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand topnav" href="#">MyAstonSpace</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="#Home">Home</a>
                    </li>
                    <li>
                        <a href="#Undergraduate Information">Undergraduate Information</a>
                    </li>
                    <li>
                        <a href="#Post-Grad Information">Post-Grad Information</a>
                    </li>
                     <li>
                        <a href="#International Students">International Students</a>
                    </li>
                     <li>
                        <a href="#Contact Us ">Contact Us </a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
      </div>
        <!-- /.container -->
    </nav>

<!-------------------------------------------------------------------------------------------------->
<?php

if(isset($_POST['prop_post'])){

    /// Variables
    $prop_title = $_POST['prop_title'];
    $prop_add = $_POST['prop_add'];
    $prop_postcode = $_POST['prop_postcode'];
    $prop_bed = $_POST['prop_bed'];
    $prop_type = $_POST['prop_type'];
    $prop_price = $_POST['prop_price'];
    $prop_desc = $_POST['prop_desc'];


    //getting the image
    $prop_image = $_FILES['prop_image']['name'];
    $prop_image_tmp = $_FILES['prop_image']['tmp_name'];

    move_uploaded_file($prop_image_tmp,"includes/prop_img/$prop_image_tmp");

    $insert_property = "insert into properties (prop_id,prop_title,prop_address,prop_postcode,prop_img,prop_radius,prop_bedrooms,prop_type,prop_price,prop_course,prop_desc,prop_share) values ('','$prop_title','$prop_add','$prop_postcode','$prop_image','','$prop_bed','$prop_type','$prop_price','','$prop_desc','')";

    $insert_prop = mysqli_query($connect, "$insert_property");

    if ($insert_prop){
        echo"Property has been uploaded.";


        }

    }

?>



 <div class="container" style="height:550px;">
  <h3>Add a New Property to MyAstonSpace</h3>
  <form action="landlord_addproperty.php" method="POST" enctype="multipart/form-data" role="form">
    <div class="form-group">
      <label for="Title">Title:</label>
      <input type="Title" class="form-control" name="prop_title" placeholder="Enter Title" >
    </div>
    <div class="form-group">
      <label for="Address">Address:</label>
      <input type="Address" class="form-control" name="prop_add"  placeholder="First Line, Town, City, County" style="width:750px;" >
      <input type="Address" class="form-control" name="prop_postcode"  placeholder="Postcode" style="width:350px; float:right; margin-top:-33px;" >
    </div>
    <div class="form-group">
      <label for="sel2">No of bedrooms:</label>
      <select class="form-control" name="prop_bed" id="sel2" >
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
      </select>
       <label for="sel1">Type of Property:</label>
      <select class="form-control" name="prop_type" id="sel3" >
        <option>Halls</option>
        <option>Flat</option>
        <option>Terrace Home share</option>
        <option>Semi Detactched Home share</option>
      </select>
      <div class="form-group">
      <label for="Price">Price(£):</label>
      <input type="Price" class="form-control" name="prop_price"  placeholder="Enter Price" >
    </div> 
    </div>
    <form action="" method = "POST" enctype="multipart/form-data">
    <input type="file" name="prop_image"  >
    </form>
    <div class="form-group">
      <label for="Description">Description:</label>
      <input type="Description" class="form-control" name="prop_desc"  placeholder="Enter Description" >
    </div>

    <center>
    <button type="submit" class="btn btn-primary" name="prop_post" style=" background-color:#337AB7; color:white;">Submit</button>
    </center>  
  </form>
</div>



<!-------------------------------------------------------------------------------------------------->

<?php
include ("footer-inc.php");
?>
  • 写回答

2条回答 默认 最新

  • dqingn8836 2016-03-17 18:08
    关注
    <button type="button" name="myBotton" value="num">
    <script type="text/javascript">
    function buttonAction(){
    
    // code here
    
    }
    
    document.form.myBotton.onclick = buttonAction;
    </script>
    </button>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错