-1

This is my code:

     <html>
<HEAD>
<TITLE>Test Input</TITLE>
</HEAD>
<body>
<?php
 $nume = $_GET['nume'];
 $cif = $_GET['cif'];
 $email = $_GET['email'];
 $telefon = $_GET['telefon'];
 $tip = $_GET['tip'];
 $produs = $_GET['produs'];
 $pret = $_GET['pret'];
 $stoc = $_GET['stoc'];
 $transport = $_GET['transport'];
 $judet = $_GET['judet'];
 $adresa = $_GET['adresa'];
 $empty = $_GET['empty'];
 
 ?>
<form action="fgo-wise.php" method="get" >
Name: <input type="text" name="nume" value="<?php echo $nume;?>"><br>
TIP: <select name="tip">
  <option value="pf">PF</option>
  <option value="pj">PJ</option>
</select><br>
CIF: <input type="text" name="cif" value="<?php echo $cif;?>"><br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>"><br>
Telefon: <input type="text" name="telefon" value="<?php echo $telefon;?>"><br>
Judet: <input type="text" name="judet" value="<?php echo $judet;?>"><br>
Adresa: <input type="text" name="adresa" value="<?php echo $adresa;?>"><br>
Produs/Serviciu: <input type="text" name="produs" value="<?php echo $produs;?>"><br>
Pret: <input type="text" name="pret" value="<?php echo $pret;?>"><br>
Cantitate: <input type="number" name="stoc" value="<?php echo $stoc;?>"><br><br>
<!--- Al doilea produs ---><br><br>
Produs/Serviciu: <input type="text" name="produs2"><br>
Pret: <input type="text" name="pret2" ><br>
Cantitate: <input type="number" name="stoc2" ><br>
UM: <input type="text" name="um"><br>
TVA: <input type="number" name="tva"><br><br>
<--- Transport ---><br><br>
Serviciu: <select name="transport">
 <option value=""></option>
  <option value="Transport Curier">Transport Curier</option>
</select><br><br>
Pret: <input type="text" name="prett"><br><br>
Cantitate: <select name="stoct">
 <option value=""></option>
  <option value="1">1</option>
</select><br><br>
UM: <select name="umt">
 <option value=""></option>
  <option value="buc">BUC</option>
</select><br><br>
TVA: <select name="tvat">
 <option value=""></option>
  <option value="19">19</option>
</select><br><br>


<input type="submit">
</form>
</body>
</html>

When I submit the URL it is like this:

http://mydomain.ro/comenzi/fgo-wise.php?nume=Casut+Claudiu&tip=pf&cif=440250&email=klaucasut%40gmail.com&telefon=0743678321&judet=Satu-Mare&adresa=Strada+Paulesti%2C+UP+4%2C+ap.+5&produs=Tastatura+Laptop+Lenovo+Y700-17ISK+iluminata+UK&pret=250.0000&stoc=1&produs2=&pret2=&stoc2=&um=&tva=&transport=&prett=&stoct=&umt=&tvat=

I want to submit only filled fields.

Dave
  • 5,108
  • 16
  • 30
  • 40
Velicu Cristian
  • 27
  • 1
  • 10
  • 1
    You could make a loop that checks if the inputs are empty – J.vee Dec 10 '18 at 14:09
  • Instead of just submitting it as pure html, you can write a javascript function which reads the form, and submits the fields that you want. – JoSSte Dec 10 '18 at 14:13
  • 1
    Please check this stack overflow [post](https://stackoverflow.com/questions/3190464/php-check-if-any-posted-vars-are-empty-form-all-fields-required) it looks similar as your problem – J.vee Dec 10 '18 at 14:13

1 Answers1

-1

Use if else statement for validating value. and you can use POST method for that. like:

<?php if(isset($nume)) { echo $nume; }?>