Content of your reminder file:
<?php
include "classes.php";
$orgFile = new ModFile;
$orgFile->loadContent('cronpart2.txt');
$size=$orgFile->countLine();
$orgFile->displayContent();
?>
Select your options:
Add a line
Delete a line
Modify a line
Line No. to Delete/Modify:
<?php
for ($i=0; $i<$size; $i++) {
echo "$i";
}
?>
Content to Add/Modify:
<?php
echo "Hour";
echo "";
for ($hour=1; $hour<=24; $hour++) {
echo "$hour";
}
echo "";
echo "Minute";
echo "";
for ($min=0; $min<=59; $min++) {
if ($min<10){
echo "$min";
}
else {
echo "$min";
}
}
echo "";
echo "Day";
echo "";
for ($day=1; $day<=31; $day++) {
echo "$day";
}
echo "";
echo "Month";
echo "";
for ($month=1; $month<=12; $month++) {
echo "$month";
}
echo "";
echo "Year";
echo "";
echo "Email";
echo "";
echo "Message";
echo "";
?>
lab6part2decision.php
<?php
if (!isset($_POST["doWhat"])){
die("No selection made.Back");
}
$choice=$_POST["doWhat"];
include "classes.php";
$oldFile = new ModFile;
$oldFile->loadContent("email.txt");
$oldFile->countLine();
switch ($choice) {
case "add":
if (!preg_match('/\b\d\d\d\d\b/', trim($_POST['year']))) {
die("Year is not valid.
Back");
}
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", trim($_POST['email']))) {
die("Email is not valid.
Back");
}
$new=$_POST['hour'].",".$_POST['minute'].",".
$_POST['day'].",".$_POST['day'].",".$_POST['month'].",".
trim($_POST['year']).",".trim($_POST['email']).",".trim($_POST['message']);
$oldFile->addLine($new);
$oldFile->countLine();
$oldFile->writeToFile('email.txt');
break;
case "delete":
$lineToDelete=$_POST["chooseLine"];
$oldFile->deleteLine($lineToDelete);
$oldFile->countLine();
$oldFile->writeToFile('email.txt');
break;
case "modify":
$lineToModify=$_POST["chooseLine"];
if (!preg_match('/\b\d\d\d\d\b/', trim($_POST['year']))) {
die("Year is not valid.
Back");
}
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", trim($_POST['email']))) {
die("Email is not valid.
Back");
}
$change=$_POST['hour'].",".$_POST['minute'].",".
$_POST['day'].",".$_POST['day'].",".$_POST['month'].",".
trim($_POST['year']).",".trim($_POST['email']).",".trim($_POST['message']);
$oldFile->modifyLine($lineToModify,$change);
$oldFile->countLine();
$oldFile->writeToFile('email.txt');
break;
}
?>
Content of your REVISED reminder file:
<?php
$oldFile->countLine();
$oldFile->displayContent();
?>
Back for More Change