PHP Javascript forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric.Thomas.Moore@gmail.com

    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=\"changeda y\" METHOD=\"post\"
    ACTION=\"worken tries.php\">\n" ;
    echo "<SELECT NAME=\"xselecte d_date\"
    onchange=\"mySu bmit('changeday ')\";>\n";
    for($i=0;$i<$pa st_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($xselect ed_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

  • E-Mo

    #2
    Re: PHP Javascript forms


    Eric.Thomas.Moo re@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=\"changeda y\" METHOD=\"post\"
    ACTION=\"worken tries.php\">\n" ;
    echo "<SELECT NAME=\"xselecte d_date\"
    onchange=\"mySu bmit('changeday ')\";>\n";
    for($i=0;$i<$pa st_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($xselect ed_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

    Comment

    • E-Mo

      #3
      Re: PHP Javascript forms

      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.



      Eric.Thomas.Moo re@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=\"changeda y\" METHOD=\"post\"
      ACTION=\"worken tries.php\">\n" ;
      echo "<SELECT NAME=\"xselecte d_date\"
      onchange=\"mySu bmit('changeday ')\";>\n";
      for($i=0;$i<$pa st_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($xselect ed_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

      Comment

      • Ron Barnett

        #4
        Re: PHP Javascript forms

        <Eric.Thomas.Mo ore@gmail.comwr ote in message
        news:1159815623 .857781.165980@ b28g2000cwb.goo glegroups.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=\"changeda y\" METHOD=\"post\"
        ACTION=\"worken tries.php\">\n" ;
        echo "<SELECT NAME=\"xselecte d_date\"
        onchange=\"mySu bmit('changeday ')\";>\n";
        for($i=0;$i<$pa st_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($xselect ed_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


        -----------------------------------------------------------------------------------------
        For labellers and labelling supplies visit www.labelzrus.co.uk


        Comment

        • Chuck Anderson

          #5
          Re: PHP Javascript forms

          Eric.Thomas.Moo re@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=\"changeda y\" METHOD=\"post\"
          ACTION=\"worken tries.php\">\n" ;
          echo "<SELECT NAME=\"xselecte d_date\"
          onchange=\"mySu bmit('changeday ')\";>\n";
          for($i=0;$i<$pa st_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($xselect ed_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_global s 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_global s 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_global s on because
          of the security issues.

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

          --
          *************** **************
          Chuck Anderson • Boulder, CO

          *************** **************

          Comment

          Working...