I have an html page with a form. In the form I have a search function and a delete function that will be available in each results’ row, in this way:
..<td><img src="delete.gif" style="cursor: pointer" onClick="javascript:delete();"></td>..
<input type="submit" value="search" onClick="javascript:search();">
In a . js file I have both functions passing the parameters to a php file via jquery’s ajax function.
Let’s go to the php file:
There are no problems with the search function: I get the parameters by $_REQUEST and I do a select query.
By clicking delete.gif in the form, I get to the delete function. The query deletes the selected row and right after I need to call the search function so I can show the results without the deleted row.
And here comes the trouble: both functions use $_REQUEST to build the queries so when calling search function after deleting I have the delete parameters stored in $_REQUEST.
How can I recover the search parameters I had in $_REQUEST in the first search so I can do that search again after deleting??
Here’s a glimpse of the delete function in the php file:
function deleteResult($_REQUEST['param1'],$_REQUEST['param2'], $_REQUEST['param3'])
{
$strSqlDelete = "DELETE FROM …"; // query working in database
//here the connecting to the database code
$result = search($_REQUEST['param1'],$_REQUEST['param2'], $_REQUEST['param3']);
echo utf8_encode($result);
exit();
}
Thanks a lot!!
It’s not too safe to use
$_REQUESTsuperglobal. Use$_POSTor$_GETdepending on your method. To store something for later use use$_SESSIONsuberglobal array.Then you can use
$_SESSION['param1']anywhere else within your site even after page reloading.