proggybilly
Programmer
I have a php page where a user can set information requested and upon submit it writes the information to a file. On my form I have two check boxes. If I check both of them and click submit, the information is put into the file, but when the page reads in the file, I cannot get the first checkbox ti display it's check mark. It should be performing a checked=checked if a certain value is true. The bottom one works fine as you will see in my code, they are basically the same. And it doesn't matter if it is both checked or just the first one checked it still wont do what it needs to do.
configsys.php:
ivrconfig.conf file:
configsys.php:
Code:
<?php
if($_POST['submit'])
{
//Will write the data collected for the configuration to a file
$ip_addr = '172.16.254.3';
$gateway = '172.16.254.1';
$netmask = '255.255.255.0';
$etreby = $_POST['ivr'];
$ivrport = $_POST['ivrport'];
$vm_ext = '198';
$down = '196';
$lang = $_POST['lang'];
$rsync1 = $_POST['rsync1'];
$rsync2 = $_POST['rsync2'];
$rsync3 = $_POST['rsync3'];
$rsync4 = $_POST['rsync4'];
if(!isset($_POST['rsyncme']))
{
$check = "off";
}else{
$check = $_POST['rsyncme'];
}
if(!isset($_POST['vpn']))
{
$vpn = "off";
}else{
$vpn = "vpntomsi";
}
$file = "/etc/asterisk/ivrconfig.conf";
$command = "/var/[URL unfurl="true"]www/ivrconfig/ivrconfig";[/URL]
$opfile = fopen($file, 'w') or die('Cannot open file');
$stringdata = $ip_addr . "\n" . $netmask . "\n" . $gateway . "\n" . $etreby . "\n" . $ivrport . "\n" . $vm_ext . "\n" . $down . "\n" . $lang . "\n" . $rsync1 . "\n" . $rsync2 . "\n" . $rsync3 . "\n" . $rsync4 . "\n" . $check . "\n" . $vpn;
fwrite($opfile, $stringdata);
fclose($opfile);
}
$file1 = file("/etc/asterisk/ivrconfig.conf") or die('Cannot open ivrconfig.conf');
?>
<html>
<head>
<title>Werks Configuration</title>
</head>
<form action="configsys.php" method="post">
<?php
require('header.php');
?>
<p></p>
<table bgcolor="grey" align="center">
<tr>
<th align="center"><font align="center">Enter the information you wish to assign to this device</font></th>
</tr>
<tr>
<td>IVR Server IP:</td>
<td><input type="text" name="ivr" value="<? echo $file1[3] ?>"></td>
</tr>
<tr>
<td>IVR Server Port:</td>
<td><input type="text" name="ivrport" value="<? echo $file1[4] ?>"></td>
</tr>
<tr>
<td>M for Multilingual or E for English:</td>
<td><input type="text" name="lang" value="<? echo $file1[7] ?>"></td>
</tr>
<tr>
<td>IP Address of resync pc:</td>
<td><input type="text" name="rsync1" value="<? echo $file1[8] ?>"></td>
</tr>
<tr>
<td>Rsync username:</td>
<td><input type="text" name="rsync2" value="<? echo $file1[9] ?>"></td>
</tr>
<tr>
<td>Rsync password:</td>
<td><input type="text" name="rsync3" value="<? echo $file1[10] ?>"></td>
</tr>
<tr>
<td>Rsync virtual directory:</td>
<td><input type="text" name="rsync4" value="<? echo $file1[11] ?>"></td>
</tr>
<tr>
<td><input type='checkbox' name='rsyncme' <?php if($file1[12] == "on"){echo 'checked="checked"';} ?>> Enable Rsync Backup</td>
</tr>
<tr>
<td><input type='checkbox' name='vpn' <?php if($file1[13] == "vpntomsi"){echo 'checked="checked"';} ?>> Enable VPN to MSI</td>
</tr>
<tr>
<td><input type='submit' name='submit' value='Submit'></td>
</tr>
</table>
</form>
<?
// End Config Display
?>
</html>
ivrconfig.conf file:
Code:
172.16.254.3
255.255.255.0
172.16.254.1
63.237.119.48
7004
198
196
M
192.168.1.1
bill
12345
phonesync
on
vpntomsi