Hi
I am trying to set up a script where the user can add, edit and delete classes (as in, events).
I have got it so that it submits 6 variables to a flat file database and I can get it to display but I am having trouble getting it able to edit.
I am not sure how to use the GET method and show the variables according to the one sent with GET.
I have it so that you view the classes and you can click a link which takes you to classes_edit.php under it's unique id. E.g. classes_manage.php?id=4939 (where 4939 would be the id of the corresponding class).
On the classes_edit.php page I would like to be able to view all the variables of the class which id I had clicked on.
If I can get the variables of that id then I presume I can have the fields already filled out.
Here is my code so far. It doesn't go.
<?
#####################
#
# Classes edit
#
#####################
session_start();
require_once("includes/config.php");
$userinfo1 = file("classes.txt");
foreach($userinfo1 as $key1 => $val1)
{
$data1[$key1] = explode("|", $val1);
}
$edit_id = $_GET['id'];
$titler = $_POST["title"];
$dayr = $_POST["day"];
$time_startr = $_POST["time_start"];
$time_finishr = $_POST["time_finish"];
$aboutr = $_POST["about"];
if($_SESSION["valid"] == true)
{
if($_POST["action"] == "send")
{
$id = rand(1000, 9999);
$filename = 'classes.txt';
$pipe = "|";
$cr = "\n";
$data .= $titler . $pipe . $dayr . $pipe . $time_startr . $pipe . $time_finishr . $pipe . $aboutr . $pipe . $idr . $cr;
$fp = fopen($filename,"w");
if($fp){
fwrite($fp,$data); // Write information to the file
fclose($fp); // Close the file
$main .= 'Class changed! To view it, head over to <a href=../classes.php">classes</a>';
}
}
if($_POST["action"] != "send")
{
$main .= "<form action='classes_edit.php' method='post'>
The class title<br />
<input class=textField type=text name=title><br /><br />
What day is it?<br />
<input class=textField type=text name=day><br /><br />
What time does it go to?<br />
Start <input class=textField type=text name=time_start>
Finish <input class=textField type=text name=time_finish>
<br /><br />
About this class
<br /><textarea rows=30 cols=80 name=about></textarea><br><br>
<input class=button type=submit value=Send>
<input type=hidden name=action value=send>
</form>";
}
}
else
{
header("Location: index.php");
}
$page = "compose";
require_once("includes/template.php");
?>