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 8 of 8

Thread: $_get

  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts

    $_get

    Ok, so the first part is a function, but im going to add the whole thing, just the main part.

    Function in main file:
    PHP Code:
    <button type="button" onclick="accept(<? echo $row['id']; ?>, "Accepted", "apply");">

    function accept($id, $check, $page)
    {
    ...

    xmlhttp.open("GET","check.php?id="+$id+"&check="+$check+"&page="+$page",true);
    xmlhttp.send(null);
    }
    check.php where the stuff happens:
    PHP Code:
    <?
    include("config.php");

    $page $_GET['page'];

    if (
    $page == "apply"){ 
    $id $_GET['id'];
    $check $_GET['check'];

    $aq mysql_query("UPDATE applications SET pending = '$check' WHERE id = '$id'");
    }
    ?>
    Im not sure if the problem is because of the if ($page == "apply"){ in check.php or if its the function accept($id, $check, $page) part.

    Edit: I just went to this link: check.php?id=15&check=Accepted&page=apply : and it worked, so im guessing the problem is from the function
    Last edited by Ndogg; 03-05-2010 at 06:28 AM.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Check to make sure the function is generating a correct URL with Firebug or Tamper Data. And always sanitize your DB inputs.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    Code:
    function accept($id, $check, $page)
    {
    ...
    
    xmlhttp.open("GET","check.php?id="+$id+"&check="+$check+"&page="+$page",true);
    xmlhttp.send(null);
    }
    to this
    Code:
    function accept(id, check, page)
    {
    ...
    
    xmlhttp.open("GET","check.php?id="+id+"&check="+check+"&page="+page",true);
    xmlhttp.send(null);
    }
    and stop using short open tags.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    That doesnt work either.

  • #5
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Code:
    function accept(id, check, page)
    {
    ...
    
    xmlhttp.open("GET","check.php?id="+id+"&check="+check+"&page="+page+"",true);
    xmlhttp.send(null);
    }
    Try that?

  • #6
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    Nope

  • #7
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    PHP Code:
    <button type="button" onclick="accept(<? echo $row['id']; ?>, "Accepted", "apply");">
    Uh, no. Two problems. First, you can't wrap the event handler in "double quotes" and use "double quotes" for the arguments. Switch the argument values to 'single quotes'. Second, the value from the PHP $row['id'] variable needs to be wrapped as well.

  • Users who have thanked bdl for this post:

    Ndogg (03-06-2010)

  • #8
    Regular Coder
    Join Date
    Jun 2009
    Posts
    278
    Thanks
    78
    Thanked 2 Times in 2 Posts
    Thankyou, that works.


  •  

    Posting Permissions

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