javascript - Sending ID to php via load function

285

I have the below javascript function and php file. I want to take the id in the URL and send it to PHP so that I can query the data by the particular ID on the page. Here is what I have so far. Let me know what needs to be changed in order to get this to work. Thanks

javascript:

/*adding data*/
dhx.ready(function () {
    dhx.ui.fullScreen();
    dhx.ui({
        view: "scheduler",
        id: "scheduler"
    });
    $$("scheduler").load("placevents.php?id=" + getID, "scheduler");

    /*preselects Month view*/
    $$("scheduler").$$("month").show();
    $$("scheduler").$$("buttons").setValue("month");
});

PHP:

//Retrieve logged in user
$test = "[email protected]$_REQUEST['id']";

$scheduler = new schedulerConnector( $res, "MySQL" );
$scheduler -> enable_log( "log.txt", true );
$scheduler -> render_table("events LEFT JOIN tblfollowers ON events.id_user = tblfollowers.username"
        . " WHERE events.status = 'active' AND((events.id_user) ='$test')"
        . " GROUP BY events.event_id, events.event_name, events.user_name, events.id_user, events.time, events.details, events.location, events.dresscode"
        . " Order By events.timestamp DESC","event_id","start_date, start_date,event_name,details");
$scheduler -> render_sql("select event_id, start_date, end_date, event_name, details from events ");
335

Answer

Solution:

Please post full source code, however I think that there are two error first you must modify this:

$test = "[email protected]$_REQUEST['id']";

Into this:

$test = $_REQUEST['id'];
mysql_real_escape_string($test);

This help you to prevent sql injection.

And as I say above I don't know you source code but I think that there are an other error:

$$("scheduler").load("placevents.php?id=" + getID, "scheduler");

Try to modify it into this:

$$("scheduler").load("placevents.php?id=" + getID + "&scheduler");

People are also looking for solutions to the problem: php - How do i change my file name after i have removed all '?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.