In ICTM Framework, We have to send some data to open a new URL and avoid showing what data is sending, we can send the data in the background. To prevent sent data from showing at the URL, here are some simple steps which give significant effects in the coding:
in HTML we can carry data via the onClick function or data attribute
<a href="#" onClick="OpenURL(2)"> My Page </a>
<!-- here 2 is assume id of the data row -->
In Java Script, the OpenURL function will process:
function OpenURL(id) {
// Create a form
var form = document.createElement("form");
form.method = "POST";
form.action = "URL of new Page";
// Create an input field for the action
var actionInput = document.createElement("input");
actionInput.type = "hidden";
actionInput.name = "action";
actionInput.value = "action value";
var idinput = document.createElement("input");
idinput.type = "hidden";
jobinput.name = "id";
idinput.value = id;
// Append the action input field to the form
form.appendChild(actionInput);
form.appendChild(idinput);
// Append the form to the body
document.body.appendChild(form);
// Submit the form
form.submit();
}
In the Controller of the New page, the value of the ID will show accordingly so that we can run the remaining code with the data sent by the previous page.
public function newMethod(){
if(!isset($_POST['action'])){
//codes for default path to this method
}
elseif(isset($_POST['action']) && $_POST['action'] =='action value'){
echo $_POST['id']; // 2
// remaining code
}
}
recent comments