Forum Moderators: coopster
<?php
$foo = 1;
if(isset($foo)) {
echo 'foo is set';
} else {
echo 'foo is not set';
}
if(isset($bar)) {
echo '<br>bar is set';
} else {
echo '<br>bar is not set';
}
?>
foo is set
bar is not set
if(isset($_POST['cb1'])) {
$sql="INSERT INTO test_table (cb1)
VALUES('{$_POST['cb1']}')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
<input name="chk[]"
[pre]<?php
if(count($_POST)) {
if(isset($_POST['chk']) && $count = count($_POST['chk'])) {
for($i = 0; $i < $count; $i++) {
echo '<br>' . $_POST['chk'][$i];
}
}
}
?>[/pre]
[pre]<?php
$key_names = array(
'foo',
'bar',
'hello',
'world'
);
foreach($key_names as $key) {
if(isset($_POST[$key])) {
echo '<br>' . $_POST[$key];
}
}
?>[/pre]
foreach($key_names as $key) {
if(isset($_POST['$key'])) {
echo '<br>' . $_POST[$key];
}
}
and now I'm trying to sanitize it but it is becoming way too complicated