I want to send a string from one php page to another via a JavaScript page. The string is sent through upon the push of a button. The name of the button is changed each time it is displayed and the name of the button is the one that is sent through. The problem is, it is not getting displayed in next php page but the alert() function outputs the string as required. What is wrong with the code?
Here is the php code in the first page
echo "<form method = 'post' action = 'passer.php'>
<input type = 'submit' value = 'play' name = '$ball'></input>
</form>";
Here's the javascript code
$(':input').click(function(){
var cat = $(this).attr("name");
alert(cat);
console.log(cat);
$.post("studSport.php",{input: cat}, function(data){
});
});
And the php code in the next page { $receiver = "";
if(isset($_POST['input'])){
$receiver = $_POST['input'];
echo $receiver;
} else{
echo " it is empty";
}
}
The output is always "it is empty" even though the alert() displays the right variable. What is wrong with the code, why wont $receiver be displayed?
var_dump($_POST)to see what did you receive?