i have a php page which i should post some data to it like this:
$player=$_POST['player']; $age=$_POST['age']; $data=$_POST['data'];
but some times my page posts data and some times it shouldn't, when i dont post data i got Undefined index: error, is there any way to skip $_POST['data'] when no data is posted?
Use simple if (isset($_POST['key']))
:
$player = isset($_POST['player']) ? $_POST['player'] : '';
$age = isset($_POST['age']) ? $_POST['age'] : '';
$data = isset($_POST['data']) ? $_POST['data'] : '';
Or better, but every value to some 'refix':
<input name="Data['player']"/>
and in php just do:
if (isset($_POST['Data'])) {
$player = $_POST['Data']['player'];
/* ... */
}