cant get the value from the textbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

cant get the value from the textbox

Post by pleigh »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi, i have this code

Code: Select all

if ($_REQUEST["startdate"]) {
$startdate = $_REQUEST["startdate"];
} else {
$startdate = "2006-06-01";
}
								
$enddate = $_POST["enddate"];
								
if ($startdate) {
$sqlstart = "AND date(l.date) >= '" . $startdate . "' ";
}
								
if ($enddate) {
$sqlend = "AND date(l.date) <= '" . $enddate . "' ";
}
and inside the <td></td>

Code: Select all

if ($startdate) {
echo "Start Date<br><input id=\"startdate\" name=\"startdate\" type=\"text\" size=\"25\"><a href=\"javascript:NewCal('startdate','ddmmyyyy')\">
<img src=\"javascript/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
}

if ($enddate) {
echo "End Date<br><input id=\"enddate\" name=\"enddate\" type=\"text\" size=\"25\"><a href=\"javascript:NewCal('enddate','ddmmyyyy')\">
<img src=\"javascript/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Pick a date\"></a>";
}
first problem is that when i run this code, there is only one textbox that appears, the startdate textbox, when i tried to edit the second textbox, replaced the $enddate with $startdate, it will appear. next problem is that there are no values passed frm the textbox to the $_REQUEST["startdate"] and $_REQUEST["enddate"], the effect is that i cannot filter the query with the specified date.

hope you can help me. thanks very much.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please try

Code: Select all

echo '<pre>_REQUEST: ', var_export($_REQUEST); echo '</pre>';
echo '<pre>_GET: ', var_export($_GET); echo '</pre>';
echo '<pre>_POST: ', var_export($_POST); echo '</pre>';

if ($_REQUEST["startdate"]) {
  $startdate = $_REQUEST["startdate"];
} else {
  $startdate = "2006-06-01";
}

$enddate = $_POST["enddate"];

echo '<pre>startdate: ', var_export($startdate); echo '</pre>';
echo '<pre>enddate: ', var_export($enddate); echo '</pre>';

if ($startdate) {
  $sqlstart = "AND date(l.date) >= '" . $startdate . "' ";
}
                        
if ($enddate) {
  $sqlend = "AND date(l.date) <= '" . $enddate . "' ";
}
and post the output.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

hi, thanks for the reply, i did that code and the output is
_REQUEST: array (
'tab' => 'td',
'rpt' => '16',
'sort' => 'daily',
'sortmonth' => '',
'sortweek' => '200618',
'startdate' => '',
'enddate' => '',
'PHPSESSID' => '7e91d165cab6df3a9e742593592cefad',
)

_GET: array (
'tab' => 'td',
'rpt' => '16',
'sort' => 'daily',
'sortmonth' => '',
'sortweek' => '200618',
'startdate' => '',
'enddate' => '',
)

_POST: array (
)

startdate: NULL

enddate: NULL
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

maybe this one will help, i think there is a problem when it comes to the format of the date, because in my javascript, the format is ddmmyyyy, and then the format in php is YYYY-MM-DD...i am just guessing, and if that is the problem, how will i be able to convert the javascript format to YYYY-MM-DD?

:)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Your form's method is GET. Therefore
pleigh wrote:$enddate = $_POST["enddate"];
doesn't work. Either change the form's method to POST or use $_GET["enddate"].

You must have changed your script to get
pleigh wrote:startdate: NULL
.
Post Reply