Home > database >  form only submits a post when form is empty problem
form only submits a post when form is empty problem

Time:09-17

Hello im trying to make a form that uploads a video file with images, tags and video name (vn stands for video name). which would upload all of this with a press of a button with post. while this worked in the past currently it isnt working and instead stops without uploading the data through post, however when i present the form with empty inputs it decides to go through with the post but then gets caught with the check if the forms are filled. below is the code

<form method="post" action="" enctype="multipart/form-data">
   <div >

    <label>
       Choose Your Video <input type="file" id="file" name="file" hidden="">
        </label><br><br><br><br></div>
        <div >
<label>
       Choose Your cover image <input type="file" id="images" name="image" hidden="">
        </label></div>
       

        <input type="text" placeholder="tags" onclick="" name="tags" id="tags" >
 
 <input type="text" placeholder="video name" name="vn" >
<div >
    <label>
  upload <input  type="submit" name="submit2345" hidden="">
        </div></label>  
</form>

php (not all of it just the bits you need, im not showing all of it because it spreads across many lines). The check for the video file is lower and i haven't implemented a cover image yet because of this problem

<?php
if(isset($_POST["submit2345"]))
{
  
    header1("eee");
    If(rtrim($_POST['tags'])!="#" && rtrim($_POST['vn']!= "" )){

css if it matters

#vupb{
    background-color: white;
    box-shadow: 2px 4px 10px rgb(0 0 0 / 40%), 8px 2px 16px rgb(0 0 0 / 40%);
    border-radius: 20px;
    padding-top: 30vh;
    width: 30vw;
    margin-left: 30vw;
    margin-top: 2vh;
    padding-bottom: 10vh;
 }
 .ca{
      width: 20vw;
      overflow-x: hidden;
    overflow-x: hidden;
      border-radius: 5px;
      border: 0px solid lightgrey;
      background-color: limegreen;
      color:white;
      font-weight: 1000;
      font-size: large;
      margin-left: 5vw;
      margin-top: 5vh;
      padding-top: 2vh;
      padding-bottom: 2vh;
    }
    .ca:hover{
      background-color: #2bb32b;
      color: lavender;
      cursor: pointer;
    }
 
    .login input[type=file]{
    display:none;
    }
    .btn{
        width: 7vw;
        height: 5vh;
      padding-top: 1vh;
      padding-bottom: 1vh;
      border-radius: 5px;
      border: 0px solid black;
      background-color: #1877f2;
      color:white;
      font-weight: 1000;
      font-size:medium;     
      margin-left: 18vw;
      margin-top: -33.5vh;
            }
            .btn:hover{
                background-color: #186edf;
      color: lavender;
      cursor: pointer;
            }
            .vfi {
                border: 1px solid black;
                width: 12vw;
                height: 14vh;
                overflow-x: hidden;
    overflow-x: hidden;
                text-align: center;
                background-repeat: no-repeat;
                background-size: 100% 100%;
                margin-left: 5vw;
                margin-top: -20vh;
                font-weight: bold;
                z-index: 90;
            }
            .textbox {
      width: 20vw;
      height: 7vh;
      font-size: medium;
      border-radius: 5px;
      border: 1px solid lightgrey;
      margin-top: 15vh;
    }
    .textbox1 {
      width: 20vw;
      height: 7vh;
      font-size: medium;
      border-radius: 5px;
      border: 1px solid lightgrey;
      margin-top: 2vh;
    }
    
    
    
    .btn1{
        width: 7vw;
        height: 5vh;
      padding-top: 1vh;
      padding-bottom: 1vh;
      border-radius: 5px;
      border: 0px solid black;
      background-color: #1877f2;
      color:white;
      font-weight: 1000;
      font-size:medium;     
      margin-left: 18vw;
      margin-top: 12.5vh;
   
            }
            .btn1:hover{
                background-color: #186edf;
      color: lavender;
      cursor: pointer;
            }
            .vfi1 {
                border: 1px solid black;
                width: 12vw;
                height: 14vh;
                overflow-x: hidden;
                overflow-x: hidden;
                text-align: center;
                background-repeat: no-repeat;
                background-size: 100% 100%;
                margin-left: 5vw;
                margin-top: 5vh;
                font-weight: bold;
                z-index: 91;
            }

CodePudding user response:

Your HTML isn't valid. Most likely your POST isn't working because there are several syntax errors. Try again by using valid HTML like this

<form method="post" action="" enctype="multipart/form-data">
    <div >
        <label>
            Choose Your Video
            <input type="file" id="file" name="file" hidden=""/>
        </label>
        <br/>
        <br/>
        <br/>
        <br/>
    </div>

    <div >
        <label>
            Choose Your cover image
            <input type="file" id="images" name="image" hidden=""/>
        </label>
    </div>

    <input type="text" placeholder="tags" onclick="" name="tags" id="tags" />

    <input type="text" placeholder="video name" name="vn" />

    <div >
        <label>
            upload
            <input type="submit" name="submit2345" hidden=""/>
        </label>
    </div>
</form>
  • Related