In this code I'm tring to make it that It includes the 5 files (main, menu, pages, add a page, images add/view) and will also be editable, the add a page one is messed up becasue everytime I try and update it it doesnt update! But when I go and add a page it works... So please look over my code, Thanks.
Main (index.php) <?php if (!$img && !$cmd && $id && !$delete && !$edit) { include("pages-body.php"); } if (!$img && $cmd || $edit || $id) { include("newpage.php"); } if ($img) { include("images-body.php"); } ?> </BODY> </HTML> menu (menu.php) <HTML> <HEAD> <link href="/css/base.css" rel="STYLESHEET" type="text/css"> </HEAD> <BODY> <TABLE width=100% cellPadding=0 cellSpacing=0> <TR> <TD width=150 vAlign=top> <?php $register_globals; $db = mysql_connect("localhost","root"); mysql_select_db("base",$db); $result = mysql_query("SELECT * FROM pages",$db); while ($myrow = mysql_fetch_array($result)) { printf("<a href=\"index.php?id=%s\">%s</a><br>", $myrow["id"], $myrow["sub"]); } ?> <A href="index.php?img=1">Images</a><BR> </TD> <TD> Pages view (pages-body.php) <?php $register_globals; $db = mysql_connect("localhost","root"); mysql_select_db("base",$db); $result = mysql_query("SELECT * FROM pages",$db); while ($page = mysql_fetch_array($result)) { if ($id==$page["id"]) { printf("<font class=newstitle><b><a href=\"$PHP_SELF?edit=yes&id=%s&cmd=1\">%s</a></b></font><font class=newsnfo> - <a href=mailto:%s>%s</A> @ %s AEST</font><br>", $page["id"], $page["sub"], $page["email"], $page["name"], $page["time"]); printf("%s<br><br>", $page["msg"]); printf("<a href=\"$PHP_SELF?id=%s&delete=areyousure\">(DELETE)</a><br>", $page["id"]); } } echo "<P><a href=\"$PHP_SELF?edit=yes&cmd=1\">ADD A RECORD</a><P>"; ?></TD></TR></TABLE> Add a page (newpage.php) <?php $register_globals; $db = mysql_connect("localhost","root"); mysql_select_db("base",$db); if ($submit) { if ($id) { $sql = "UPDATE pages SET sub='$sub' msg='$msg',name='$name',email='$email',newday='$newday'"; } else { $sql = "INSERT INTO pages (sub,msg,name,email,date,time,newday) VALUES ('$sub','$msg','$name','$email','$date','$time','$newday')"; } $result = mysql_query($sql); printf("Record updated/edited!<p>Return to <A href=\"index.php?id=%s\">Index</a>", $id); } elseif ($delete == areyousure) { $sql = "SELECT * FROM pages WHERE id=$id"; $result = mysql_query($sql); echo "Are you sure you want to delete $sub?<p><a href=\"$PHP_SELF?id=$id&delete=true\">Yes</a> | <a href=\"index.php\">No</a>"; } elseif ($delete == true) { $sql = "DELETE FROM pages WHERE id=$id"; $result = mysql_query($sql); printf("$sub Record deleted!<p><a href=\"index.php\">Return</a>"); } ?> <?php if ($edit) { ?> <form method="post" action="index.php"> <?php if ($id) { $sql = "SELECT * FROM pages WHERE id=$id"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $id = $myrow["id"]; $name = $myrow["name"]; $email = $myrow["email"]; $sub = $myrow["sub"]; $msg = $myrow["msg"]; $newday = $myrow["newday"]; $width = $myrow["width"]; ?> <input type=hidden name="id" value="<?php echo $id ?>"> <?php } ?> <input type=hidden name="date" value="<?php echo date("l, F, jS Y"); ?>"> <input type=hidden name="time" value="<?php echo date("H:i:s"); ?>"> <input type=hidden name="width" value="100%"> <TABLE cellPadding="0" cellSpacing="0" border="0"> <TR> <TD>Name:</TD> <TD><input type="Text" name="name" value="<?php echo $name ?>"></TD></TR> <TR> <TD>E-Mail:</TD> <TD><input type="Text" name="email" value="<?php echo $email ?>"></TD></TR> <TR> <TD>Subject:</TD> <TD> <TABLE cellPadding="0" cellSpacing="0" border="0" width="100%"> <TR> <TD><input type="Text" name="sub" width=50 value="<?php echo $sub ?>"> <TD>New Day?</TD> <TD><input type="radio" name="newday" value="1"></TD> <TD>Yes</TD> <TD><input type="radio" name="newday" value="0"></TD> <TD>No</TD></TR></TABLE></TD></TR> <TR> <TD>Message:</TD> <TD colSpan="2"><textarea name="msg" rows="7" cols="40" wrap="virtual"><?php echo $msg ?></TEXTAREA></TD></TR></TABLE> <input type="Submit" name="submit" value="Enter information"> </form> <?php } ?> </BODY> </HTML> Images View/Add (images-body.php) <?php if ($submit) { if ($id && $img) { $sql = "UPDATE img SET img_path='$img_path',img_alt='$img_alt' WHERE id=$id"; } else { $sql = "INSERT INTO img (img_path,img_alt) VALUES ('$img_path','$img_alt')"; } $result = mysql_query($sql); echo "Record updated/edited!<p>Return to <A href=\"index.php?img=1\">Return</a>.</TD></TR></TABLE>"; } elseif ($delete == areyousure && $img) { $sql1 = "SELECT * FROM img WHERE id=$id"; $result = mysql_query($sql1); echo "Are you sure you want to delete $img_alt?<p><a href=\"$PHP_SELF?id=$id&delete=true&img=1\">Yes</a> | <a href=\"$PHP_SELF?img=1\">No</a></TD></TR></TABLE>"; } elseif ($delete == true && $img) { $sql1 = "DELETE FROM img WHERE id=$id"; $result = mysql_query($sql1); echo "$img_alt Image deleted!<p><a href=\"$PHP_SELF?img=1\">Return</a></TD></TR></TABLE>"; } else { if ($id && !$edit) { $result = mysql_query("SELECT * FROM news ORDER BY time ASC",$db); while ($myrow = mysql_fetch_array($result)) { printf("<TABLE border=0 cellPadding=0 cellSpacing=0>\n"); printf("\n<tr><td>\n<a href=%s><img src=%s width=150 height=100 border=0 alt=\"%s\"></a></td>\n<td width=200>\n</td>\n<td vAlign=top><a href=\"$PHP_SELF?id=%s&delete=areyousure&img=1\">Delete?</a><br>Info: %s<br><a href=$PHP_SELF?edit=yes&id=%s&img=1>Edit?</a></td></tr>\n",$img["img_path"], $img["img_path"],$img["img_alt"],$img["id"],$img["img_alt"],$img["id"]); } printf("</TABLE>\n"); echo "<p align=center style=font-size:25px;><a href=$PHP_SELF?edit=1&img=1>New Image</a></p></TD></TR></TABLE>"; } } ?> <?php if ($edit && $img) { ?> <form method="post" action="index.php?img=1"> <?php if ($id && $img) { $sql = "SELECT * FROM img WHERE id=$id"; $result = mysql_query($sql); $img = mysql_fetch_array($result); $id = $img["id"]; $img_path = $img["img_path"]; $img_alt = $img["img_alt"]; ?> <input type=hidden name="id" value="<?php echo $id ?>"> <?php } ?> <table border=0 cellPadding=2 cellSpacing=1> <tr> <td>Image Path:</td> <td><input type="Text" name="img_path" value="<?php echo $img_path ?>"></td></tr> <tr> <td>Text:</td> <td><input type="Text" name="img_alt" value="<?php echo $img_alt ?>"></td></tr></table> <input type="Submit" name="submit" value="Enter information"> </form></TD></TR></TABLE> <?php } ?> Any help would be apresiated! Thanks. -Ben