表单:从表单向mysql数据库表提交数据

时间:2018-09-05 09:18:02

标签: php html mysql sql html-form

单击Submit按钮打开一个空白的action.php,既没有错误消息,也没有在表中插入数据。

询问是否有人可以共享action.php的简洁代码或指导我使用同一代码。我在connection.php中有数据库登录凭据

我的表单具有以下代码:

<form class="form-horizontal" action="action.php" method="Post">
    <div class="form-group">
        <label class="control-label col-sm-2" for="vlocation">Location:</label>
        <div class="col-sm-8">
            <?php 
            $reg=$thisitem['location'];
            $sql= "select  id, location from location";          
            $res= mysql_query($sql);    
            $sql1= "select  * from location where id='$reg'";            
            $res1= mysql_query($sql1);
            $thiscat =mysql_fetch_array($res1);          
            ?>                                  
            <select name="vlocation" class="form-control" value="<?php echo $thiscat['location']; ?>">                  
                <option value="" disabled selected>Select location</option>
                <option value="<?php echo $thiscat['id']; ?>"><?php echo $thiscat['location']; ?></option>
                <?php  
                while($rows=mysql_fetch_array($res)){?>
                    <option value="<?php echo $rows['id']?>"> <?php echo $rows['location'];?> </option>
                <?php }?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vtype">Category:</label>
        <div class="col-sm-8">
            <?php 
            $reg=$thisitem['vtype'];
            $sql= "select  id, type from vtype";             
            $res= mysql_query($sql);    
            $sql1= "select  * from vtype where id='$reg'";           
            $res1= mysql_query($sql1);
            $thiscat =mysql_fetch_array($res1);          
            ?>                                  
            <select name="vtype" class="form-control" value="<?php echo $thiscat['type']; ?>">                  
                <option value="" disabled selected>Select venue category</option>
                <option value="<?php echo $thiscat['id']; ?>"><?php echo $thiscat['type']; ?></option>
                <?php  
                while($rows=mysql_fetch_array($res)){?>
                    <option value="<?php echo $rows['id']?>"> <?php echo $rows['type'];?> </option>
                <?php }?>
            </select>
        </div>
    </div>                    
    <div class="form-group">
        <label class="control-label col-sm-2" for="vname">Name:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vname" placeholder="Enter venue name">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vseo">SEO:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vseo" placeholder="Enter venue seo string">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vpremium">Premium:</label>
        <div class="col-sm-10"> 
            <input type="text class="form-control" name="vpremium" placeholder="Enter PREMIUM if venue is premium">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vrank">Rank:</label>
        <div class="col-sm-10"> 
            <input type="number" class="form-control" name="vrank" placeholder="Enter venue rank">
        </div>
    </div>                    
    <div class="form-group">
        <label class="control-label col-sm-2" for="vcontact">Contact:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vcontact" placeholder="Enter venue contact numbers">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vcapacity">Capacity:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vcapacity" placeholder="Enter venue capacity">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vprice">Price:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vprice" placeholder="Enter venue price details">
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-sm-2" for="vaddress">Address:</label>
        <div class="col-sm-10"> 
            <textarea name="vaddress" class="form-control" placeholder="Enter venue address"><?php echo $thisitem['vaddress']; ?></textarea>
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-sm-2" for="vinclusions">Inclusions:</label>
        <div class="col-sm-10"> 
            <textarea name="vinclusions" class="form-control" placeholder="Enter inclusions"><?php echo $thisitem['vinclusions']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vspaces">Spaces:</label>
        <div class="col-sm-10"> 
            <textarea name="vspaces" class="form-control" placeholder="Enter spaces available in venue"><?php echo $thisitem['vspaces']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vaccommodation">Accommodations:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vaccommodation" placeholder="Enter accommodation details">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vimages">Image Gallary URL:</label>
        <div class="col-sm-10"> 
            <input type="text" class="form-control" name="vimages" placeholder="Enter image gallary url">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vdetails">Details:</label>
        <div class="col-sm-10"> 
            <textarea name="details" class="summernote form-control" data-height="200" data-lang="en-US" placeholder="Enter venue details"><?php echo $thisitem['vdetails']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vmap">Google Map Code:</label>
        <div class="col-sm-10"> 
            <textarea name="map" class="form-control" placeholder="Enter google map code"><?php echo $thisitem['vmap']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vmtitle">Meta Title:</label>
        <div class="col-sm-10"> 
            <textarea name="vmtitle" class="form-control" placeholder="Enter meta title"><?php echo $thisitem['vmtitles']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vmkeyword">Meta Keyword:</label>
        <div class="col-sm-10"> 
            <textarea name="vmkeyword" class="form-control" placeholder="Enter meta keywords"><?php echo $thisitem['vmkeyword']; ?></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2" for="vmdescription">Meta Description:</label>
        <div class="col-sm-10"> 
            <textarea name="vmdescription" class="form-control" placeholder="Enter meta description"><?php echo $thisitem['vmdescription']; ?></textarea>
        </div>
    </div>                       
    <div class="form-group"> 
        <label class="control-label col-sm-2" for="vstatus">Status:</label>
        <div class="col-sm-10">     
            <label><input type="checkbox" name="status"> Enable</label>
        </div>
    </div>
    <div class="form-group"> 
        <div class="col-sm-offset-2 col-sm-10">
            <!-- <button type="submit" class="btn btn-default">Submit</button> -->
            <input class="btn btn-success" type="submit" name="submit" value="Submit">
            <button type="reset" class="btn btn-default">Reset</button>
        </div>
    </div>

</form>  

由于我对PHP的了解很少,因此寻求论坛支持。积极乐观

0 个答案:

没有答案