Submit Button won't appear

215 views Asked by At

UPDATE: Here it is my code so far. The download buttons now appear, but the code is printing the form closing tag instead of identifying it as a closing tag. How can I correct this? Please help. Thanks in advance!!

<HTML>
<HEAD>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/style2.css">
    <TITLE>SAE Report</TITLE>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
   $().ready(function() {
     $(".datepicker").datepicker({dateFormat:'yy-mm-dd'});
   });
</script>

</HEAD>
<BODY>
<center>
<h1>SAE Report</h1>
</center>
 <form action = "" method = "post">
 <label>Report Type</label>
    <select id="report" name="report">
        <option value="none"></option>
        <option value="new">New SAEs Report</option>
        <option value="cumulative">Cumulative SAE Report</option>
    </select>
 <label>Start Date</label><input type="text" class="datepicker" name="start">
 <label>End Date</label><input type="text" class="datepicker" name="end">
 <input type="submit" name="submit" value="Submit">
 </form>
</BODY>

 <?php
 $type='';
 $start='';
 $end='';

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

    $type=$_POST['report'];
    $start=$_POST['start'];
    $end=$_POST['end'];

    if ($type=="cumulative"){
        echo "<form action='cumulativeRptExcel.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
        echo "/form><br>";
        echo "<form action='cumulativeRptPDF.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
        echo "/form><br>";
    }
    elseif($type=='new' and $start!='' and $end!=''){
        echo "<form action='newRptExcel.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
        echo "/form><br>";
        echo "<form action='newRptPDF.php' method='post' name ='xls'>";
        echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
        echo "/form><br>";
    }
    elseif($type="new" and ($start=='' or $end=='')){
        echo "You need to select START and END date for the report";
    }   

}


?>

The report.php files contains the code to generate the excel or pdf file and make it downloadable to the user. When running those files by themselves it generates the files just fine.

2

There are 2 answers

1
Neville On BEST ANSWER

It prints /form> because from your codes that's what you asked it to print. You echoed out "/form><br>"; instead of "</form><br>"; in every line that I can see. Simply add < to fix that

2
Jose Garrido On

Change your submit button from:

 <input type="submit" value="Submit">

to

 <input type="submit" name="submit" value="Submit">

The reason behind this is the $_POST variable will only have elements that had a name inside the previous form. In your example the submit button does not have a name.