473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

PHP Javascript forms

Hey,

My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it over to a new
server and the latest versions of php, mysql, and apache. That
information is probably not relevant to the question.

His system has some javascript forms. One of which is a drop down
menu that uses the onchange functionality. Here is the code:

echo "<FORM NAME=\"changeday\" METHOD=\"post\"
ACTION=\"workentries.php\">\n";
echo "<SELECT NAME=\"xselected_date\"
onchange=\"mySubmit('changeday')\";>\n";
for($i=0;$i<$past_days;$i++){ // loop through past X days
echo "<OPTION VALUE='".$dates[$i]."' "; // output option
if ($dates[$i] == $selected_date) {echo "selected";} // hilight
currently selected
echo ">".$months[$i]."/".$days[$i]; // finish option
} // end of past months loop
echo "</SELECT>\n"; // end of pull down menu
echo "<input type=hidden name=xtech value='".$tech."'>"; // keep
currently selected tech
echo "</form>\n"; // end of change month form
I realize this is messy code, that is why this has been so hard for me.

My problem is the following:

The selected value in the menu is set to $xselected_date. Then upon a
change the form is submited back to this same php file. At the
begginning of this php script the code then does:

if (isset($xselected_date)) {blah blah blah}

But this conditional is never evaluating true. Does the select name
variable not remain declared across the form submit? If not, is there
a way around this.

Thank you in advance for the help, if i need to provide any more
information please let me know.

-Eric

Oct 2 '06 #1
4 1251

Er***************@gmail.com wrote:
Hey,

My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it over to a new
server and the latest versions of php, mysql, and apache. That
information is probably not relevant to the question.

His system has some javascript forms. One of which is a drop down
menu that uses the onchange functionality. Here is the code:

echo "<FORM NAME=\"changeday\" METHOD=\"post\"
ACTION=\"workentries.php\">\n";
echo "<SELECT NAME=\"xselected_date\"
onchange=\"mySubmit('changeday')\";>\n";
for($i=0;$i<$past_days;$i++){ // loop through past X days
echo "<OPTION VALUE='".$dates[$i]."' "; // output option
if ($dates[$i] == $selected_date) {echo "selected";} // hilight
currently selected
echo ">".$months[$i]."/".$days[$i]; // finish option
} // end of past months loop
echo "</SELECT>\n"; // end of pull down menu
echo "<input type=hidden name=xtech value='".$tech."'>"; // keep
currently selected tech
echo "</form>\n"; // end of change month form
I realize this is messy code, that is why this has been so hard for me.

My problem is the following:

The selected value in the menu is set to $xselected_date. Then upon a
change the form is submited back to this same php file. At the
begginning of this php script the code then does:

if (isset($xselected_date)) {blah blah blah}

But this conditional is never evaluating true. Does the select name
variable not remain declared across the form submit? If not, is there
a way around this.

Thank you in advance for the help, if i need to provide any more
information please let me know.

-Eric
Oct 2 '06 #2
Some more information:

This script worked on the old server but does not work on the new
server. The new server is running php 5.2 I am not sure what version
of php the old server was running but it was at least a year or 2 old.

Er***************@gmail.com wrote:
Hey,

My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it over to a new
server and the latest versions of php, mysql, and apache. That
information is probably not relevant to the question.

His system has some javascript forms. One of which is a drop down
menu that uses the onchange functionality. Here is the code:

echo "<FORM NAME=\"changeday\" METHOD=\"post\"
ACTION=\"workentries.php\">\n";
echo "<SELECT NAME=\"xselected_date\"
onchange=\"mySubmit('changeday')\";>\n";
for($i=0;$i<$past_days;$i++){ // loop through past X days
echo "<OPTION VALUE='".$dates[$i]."' "; // output option
if ($dates[$i] == $selected_date) {echo "selected";} // hilight
currently selected
echo ">".$months[$i]."/".$days[$i]; // finish option
} // end of past months loop
echo "</SELECT>\n"; // end of pull down menu
echo "<input type=hidden name=xtech value='".$tech."'>"; // keep
currently selected tech
echo "</form>\n"; // end of change month form
I realize this is messy code, that is why this has been so hard for me.

My problem is the following:

The selected value in the menu is set to $xselected_date. Then upon a
change the form is submited back to this same php file. At the
begginning of this php script the code then does:

if (isset($xselected_date)) {blah blah blah}

But this conditional is never evaluating true. Does the select name
variable not remain declared across the form submit? If not, is there
a way around this.

Thank you in advance for the help, if i need to provide any more
information please let me know.

-Eric
Oct 2 '06 #3
<Er***************@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hey,

My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it over to a new
server and the latest versions of php, mysql, and apache. That
information is probably not relevant to the question.

His system has some javascript forms. One of which is a drop down
menu that uses the onchange functionality. Here is the code:

echo "<FORM NAME=\"changeday\" METHOD=\"post\"
ACTION=\"workentries.php\">\n";
echo "<SELECT NAME=\"xselected_date\"
onchange=\"mySubmit('changeday')\";>\n";
for($i=0;$i<$past_days;$i++){ // loop through past X days
echo "<OPTION VALUE='".$dates[$i]."' "; // output option
if ($dates[$i] == $selected_date) {echo "selected";} // hilight
currently selected
echo ">".$months[$i]."/".$days[$i]; // finish option
} // end of past months loop
echo "</SELECT>\n"; // end of pull down menu
echo "<input type=hidden name=xtech value='".$tech."'>"; // keep
currently selected tech
echo "</form>\n"; // end of change month form
I realize this is messy code, that is why this has been so hard for me.

My problem is the following:

The selected value in the menu is set to $xselected_date. Then upon a
change the form is submited back to this same php file. At the
begginning of this php script the code then does:

if (isset($xselected_date)) {blah blah blah}

But this conditional is never evaluating true. Does the select name
variable not remain declared across the form submit? If not, is there
a way around this.

Thank you in advance for the help, if i need to provide any more
information please let me know.

-Eric
Hi Eric,
are you getting ANY of the variables passed into workentries.php ?

If not, you probably had Register Globals ON, on the old system, and they
would be set to off on the new one

at a 'cleaner' alternative, you could revise each variable reference to:

$_REQUEST['variablename'] where variable name is the HTML field name
Not this MUST be case perfect.

HTH
Cheers,

Ron Barnett
IT Support for Business
www.rjbarnett.co.uk

-----------------------------------------------------------------------------------------
For labellers and labelling supplies visit www.labelzrus.co.uk
Oct 2 '06 #4
Er***************@gmail.com wrote:
Hey,

My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it over to a new
server and the latest versions of php, mysql, and apache. That
information is probably not relevant to the question.

His system has some javascript forms. One of which is a drop down
menu that uses the onchange functionality. Here is the code:

echo "<FORM NAME=\"changeday\" METHOD=\"post\"
ACTION=\"workentries.php\">\n";
echo "<SELECT NAME=\"xselected_date\"
onchange=\"mySubmit('changeday')\";>\n";
for($i=0;$i<$past_days;$i++){ // loop through past X days
echo "<OPTION VALUE='".$dates[$i]."' "; // output option
if ($dates[$i] == $selected_date) {echo "selected";} // hilight
currently selected
echo ">".$months[$i]."/".$days[$i]; // finish option
} // end of past months loop
echo "</SELECT>\n"; // end of pull down menu
echo "<input type=hidden name=xtech value='".$tech."'>"; // keep
currently selected tech
echo "</form>\n"; // end of change month form
I realize this is messy code, that is why this has been so hard for me.

My problem is the following:

The selected value in the menu is set to $xselected_date. Then upon a
change the form is submited back to this same php file. At the
begginning of this php script the code then does:

if (isset($xselected_date)) {blah blah blah}

But this conditional is never evaluating true. Does the select name
variable not remain declared across the form submit? If not, is there
a way around this.

Thank you in advance for the help, if i need to provide any more
information please let me know.

-Eric

Register_globals is off, by default in Php5 and that appears to be your
problem.

Your conditional would need to be:
if (isset($_POST['xselected_date'])) {blah blah blah}

You will need to make similar changes *all over the place* (for all GET,
POST, and COOKIE variables).

I'll probably get thrashed for saying this, but if you want to see your
scripts work, ... right now ... change register_globals to on in php.ini.

This creates a potential security hole and it is not advised (hence the
default setting in Php5), so you may want to work on the more long term
solution. Most all hosts refuse to run with register_globals on because
of the security issues.

On your own server, it's your own call. Having register_globals on means
you need to be very careful how you treat POST and GET variables.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
Oct 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
3
by: bhanubalaji | last post by:
hi, I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA.. can any one help regarding this.. What's the wrong with my code? I am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.