Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Lau
    Lau is offline
    New Coder
    Join Date
    Jan 2004
    Location
    Malden, MA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable passed with GET not working as expected

    Hey everyone,

    I'm having a bit of a head scrashing problem here.
    I have a php file calling itself on submit:
    This is only part of the file (I assume this is where the problem is, although not sure):
    PHP Code:
          $url "write_review.php?class=".$titleTable."&id=".$id;
          echo 
    "url is ".$url;
          echo 
    "<form action='".$url."' method='get'>";
          
    // ============= display ===================
          
    echo "<table width=60% border=0 cellpadding=5>";
          echo 
    "<tr height=20><td colspan=2 align=center><font size=+1>Ratings</font></td></tr>";
          for (
    $i=0$i<$j ;$i++) {
            if (
    $hname[$i] != 'reviewer' && $hname[$i] != 'comment') {
              echo 
    "<tr><td align=right><i>" .$hdisplay[$i]. "</i></td>";
              echo 
    "<td align=left><input type='radio' name='".$hname[$i]."' value=1>1
                                   <input type='radio' name='"
    .$hname[$i]."' value=2>2
                                   <input type='radio' name='"
    .$hname[$i]."' value=3>3
                                   <input type='radio' name='"
    .$hname[$i]."' value=4>4
                                   <input type='radio' name='"
    .$hname[$i]."' value=5>5</td></tr>";
            }
            elseif (
    $hname[$i] == 'comment') {
              echo 
    "<tr height=20><td colspan=2 align=center><font size=+1>".$hdisplay[$i]."</font></td></tr>";
              echo 
    "<tr><td colspan=2 align=center>
                    <textarea name='"
    .$hname[$i]."' rows=5 cols=70></textarea></td></tr>";
            }
    // end elseif
          
    // end for
          
    echo "<tr><td colspan=2 align=center><input type='submit' value='Submit'></td></tr>";
          echo 
    "</table></form>"
    The echo "url is ".$url displays the right value, so it should go to that url. Instead, It goes to "write_review.php?comment="... Where does the comment come from?????
    I really don't get where that comes from at all.
    You can check it out at http://www1.coe.neu.edu/~lleccia/ISY...roj5/index.php try to write a review (id: user, pw: pass) and see when submitting
    Last edited by Lau; 04-17-2004 at 11:48 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you are useing get to pass data from form so comment is added when you submit the form

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,055
    Thanks
    10
    Thanked 95 Times in 93 Posts
    Your sample page bears no relation to the problem in the code you post , e.g. it does not use a form , I can only assume that in your real caod you managed to rewrite $url value before you actually used it.

    The only time PHP will alter your script is when rewriting urls with a session id , & unless you have set your session name to 'comment' what you describe can't happen, probbably a typo somewhere.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Lau
    Lau is offline
    New Coder
    Join Date
    Jan 2004
    Location
    Malden, MA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sidney - well.. It works. I changed get to post, and the file reload itself!

    I don't really understand why that is though...
    I'm using GET to retrieve variables from the url, so I should be using get, shouldn't I?

  • #5
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the form was adding the get vars to the url so over writing exsisting possibly

    the way to do it by get would be to have hidden fields in form for vars class and id and then when form is submitted all vars in form would be added to url


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •