...

View Full Version : $_get



Ndogg
03-05-2010, 05:25 AM
Ok, so the first part is a function, but im going to add the whole thing, just the main part.

Function in main file:

<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:


<?
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

Inigoesdr
03-05-2010, 06:34 AM
Check to make sure the function is generating a correct URL with Firebug or Tamper Data. And always sanitize your DB inputs.

_Aerospace_Eng_
03-05-2010, 07:35 AM
Change this


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

xmlhttp.open("GET","check.php?id="+$id+"&check="+$check+"&page="+$page",true);
xmlhttp.send(null);
}
to this


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.

Ndogg
03-06-2010, 12:03 AM
That doesnt work either.

nobackseat88
03-06-2010, 12:18 AM
function accept(id, check, page)
{
...

xmlhttp.open("GET","check.php?id="+id+"&check="+check+"&page="+page+"",true);
xmlhttp.send(null);
}

Try that?

Ndogg
03-06-2010, 02:11 AM
Nope :(

bdl
03-06-2010, 03:07 AM
<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.

Ndogg
03-06-2010, 10:12 PM
Thankyou, that works.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum