1

I am trying to get the field values in php, but I can't seem to get them. Tried with both post and get, to no results. I know it is supposed to be a simple solution, but I just can't see the mistake. Any help is appreciate. Thank you!

Here it is my report.html:

<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>
  $(function() {
     $(".datepicker").datepicker({dateFormat:'yy-mm-dd'});
   });
  </script>

</HEAD>
<BODY>
<center>
<h1>SAE Report</h1>
</center>
 <form action = "report.php" method = "get">
 <label>Report Type</label>
    <select id="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" id='start' >
 <label>End Date</label><input type="text" class="datepicker" id='end'>
 <input type="submit" value="Submit" id ="submit">
 </form>
</BODY>

Here it is my report.php:

<?php

$report=$_GET['report'];
   if ($report=="new"){
     $start=$_GET['start'];
     $end=$_GET['end'];
     echo 'Start date is:'.$start.' and end date is: '.$end;
   }
    else if ($report=="cumulative"){
     echo "print all SAEs";
   }    

?>

1 Answer 1

3

You are missing name attribute in HTML. Just add it:

<form action = "report.php" method = "get">
    <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" name="start" class="datepicker" id='start' >
    <label>End Date</label><input type="text" name="end" class="datepicker" id='end'>
    <input type="submit" value="Submit" id ="submit">
</form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.