简体   繁体   中英

how can i pass Date text field value to my second php page?

my first php page has a date textfield which works through jquery date picker,

i have this in my first php page:

<form id="form2" name="form2" method="post" action="report.php">

<table width="741" border="0" align="center">
<tr>
<th scope="col">
<div align="center">
<label for="date">Date:</label><input type="text" name="Date" id="Date" size="8"/>
<input name="action" type="button" id="Report" value="Generate Report" />
<input name="Clear" type="reset" id="Clear" value="Clear" onClick="window.location.reload()" />
</div>
</tr>
</table>
</form>

now i want to pass that date textfield value to my second php page... in my second php page, i have this

$date = $_POST['date'];

then i'd like to add the date textfield value here:

<tr>
<th colspan='8' align="center" bgcolor="#49166D"><font color=white size=4pt>Daily Ticket Report <?php echo "$date";?></font></th>
</tr>

On first page, you have an HTML code:

<label for="date">Date:</label><input type="text" name="Date" id="Date" size="8"/>

Name of input there starts with capital letter (Date). And in code you are taking it from $_POST using lowercase string (date).

Just change $date = $_POST['date']; to $date = $_POST['Date']; and everything should work.

And what is problem? Any errors?

All you need is to pass name of your second PHP file to

<form action="second.php"> 

If you need to debug it, just add this code at begining of your page:

var_dump($_POST);

UPDATE:

As @FAngel mentioned in his answer, you have typo in form field name, they are case sensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM