
March 24th, 2003, 09:17 AM
|
|
Registered User
|
|
Join Date: Mar 2003
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
str_replace with checkboxes
Hi All,
here is my code
test.html
[html]<td bgcolor="{COLOR}">{PICK}</td>[/html]
Please note, that code above is inside an HTML file.
test.php
PHP Code:
<?
session_start();
$filename = "test3.html";
$fd = fopen ($filename, "r");
$file= fread ($fd, filesize ($filename));
$file = str_replace("{PICK}", 'test1 <input type="checkbox" name=mycheckbox[] value="5" checked>', $file);
print($file);
?>
<!--
test2 <INPUT type='checkbox' name='<? echo $mycheckbox?>' value='XYZ' checked><BR>
-->
<?
//$test = $_POST['mycheckbox'];
// $mycheckbox = mycheckbox;
if(isset($_POST['mycheckbox'])){
if (isset($mycheckbox)){
// $mycheckbox = explode(",",$mycheckbox);
foreach ($mycheckbox As $key => $age_range) {
print $age_range .'='. $key;
}
}
}
//foreach ($mycheckbox as $checkbox){
//$authstatus = (isset($checkbox) ? 1 : 0);
//print $authstatus;
//}
//foreach($select as $name => $val)
//foreach ($_POST as $mycheckbox => $value)
foreach ($test as $te => $value)
{
print 'PASS NUMBER 1';
}
print 'REACHED THE END';
?>
All I want to do is somehow get the Checkbox value (5) printed somewhere, but only if the checkbox is checked.
I know I have a lot of duff code, so please feel free to remove any unwanted code. (Its all my testing and trying - to no avail)
Now you will notice that the Checkbox is inside a STR_REPLACE. It has to be like this unfortunetly and I'm getting to a stage where I think its imposible to find the value of the checkbox when its checked.
Please help.
Thanks,
ANISH
|