ok here it is, i have 2 bits of code i want to work in conjunction with each other, one being the site navigation code & the code of another script, il go more into detail:
SITE WIDE CODE:
PHP Code:
<?php
if (isset($_GET['page']) && isset($_GET['id']) && file_exists('mods/'.$_GET[id].'/'.$_GET[page].'.php')) {
include 'mods/'.$_GET[id].'/'.$_GET[page].'.php';
}
else {
include "mods/main.php";
}
?>
script code:
PHP Code:
switch($_GET['action'])
{
case "addtutorial":
if(!isset($_POST['add_tutorial']))
{
echo "
<table border='0' cellpadding='0' cellspacing='0' width='500'>
<form action='$self?action=addtutorial' method='post'>
<tr>
<td>Name:</td>
<td><input type='text' name='name'></td>
</tr>
<tr>
<td>Title:</td>
<td><input type='text' name='title'></td>
</tr>
<tr>
<td>Category:</td>
<td>
<select name='category'>
";
$query = mysql_query("SELECT * FROM tutorials_categorys ORDER BY id ASC") or die(mysql_error());
while($row = mysql_fetch_array($query))
{
echo "<option value='$row[id]'>$row[category]";
}
echo "
</select>
</td>
</tr>
<tr>
<td>Tutorial:</td>
<td><textarea name='tutorial' cols='40' rows='10'></textarea></td>
</tr>
</tr>
<tr>
<td>Short Description:</td>
<td><textarea name='short_description' cols='40' rows='2'></textarea></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' maxlength='50'></td>
</tr>
<tr>
<td>Show Email?</td>
<td><input type='checkbox' name='show_email' value='1' checked></td>
</tr>
<tr>
<td colspan='2'><center><input type='submit' name='add_tutorial' value='Submit New Tutorial'></center></td>
</tr>
</form>
</table>
";
}
elseif(isset($_POST['add_tutorial']))
{
$name = mysql_real_escape_string(strip_tags($_POST['name']));
$title = mysql_real_escape_string(strip_tags($_POST['title']));
$category = mysql_real_escape_string(strip_tags($_POST['category']));
$tutorial = mysql_real_escape_string(strip_tags($_POST['tutorial']));
$short_description = mysql_real_escape_string(strip_tags($_POST['short_description']));
$email = mysql_real_escape_string(strip_tags($_POST['email']));
$show_email = mysql_real_escape_string($_POST['show_email']);
$date = date("m/d/Y");
$time = time();
$error_msg = array();
if(empty($name))
{
$error_msg[] = "Please insert a name!<br />";
}
if(empty($title))
{
$error_msg[] = "Please insert a title!<br />";
}
if(empty($category))
{
$error_msg[] = "Please insert a category!<br />";
}
if(empty($tutorial))
{
$error_msg[] = "Please insert the tutorial text!<br />";
}
if(empty($short_description))
{
$error_msg[] = "Please insert a short description!<br />";
}
if(empty($email))
{
$error_msg[] = "Please insert an email!<br />";
}
if(count($error_msg)>0)
{
echo "<strong>ERROR:</strong><br>n";
foreach($error_msg as $err)
echo "$err";
}
else
{
$sql = "INSERT INTO tutorials (submitter, text, short_description, title, cat_id, date_submitted, time_submitted, show_email, email, is_validated) VALUES ('$name', '$tutorial', '$short_description', '$title', '$category', '$date', '$time', '$show_email', '$email', '0')";
mysql_query($sql) or die(mysql_error());
echo "Tutorial added for review!";
}
}
break;
case "viewcategory":
if($_GET['id'])
{
$id = (int)$_GET['id'];
$query = mysql_query("SELECT * FROM tutorials WHERE cat_id = '$id' AND is_validated = '1'") or die(mysql_error());
if(mysql_num_rows($query) == 0)
{
echo "No tutorials for this category yet!";
}
else
{
echo "<h1>Tutorials</h1>";
echo "<table border='0' cellpadding='0' cellspacing='0' width='500'>";
while($row = mysql_fetch_array($query))
{
echo "
<tr>
<td>Title:</td>
<td><b>$row[title]</b></td>
</tr>
<tr>
<td>Date Submitted:</td>
<td><b>$row[date_submitted]</b></td>
</tr>
<tr>
<td>Views:</td>
<td>$row[views]</td>
</tr>
<tr>
<td>Short Description:</td>
<td>$row[short_description]</td>
</tr>
<tr>
<td>Submitter:</td>
<td>$row[submitter]</td>
</tr>
<tr>
<td colspan='2'><center><b><a href='$self?action=viewtutorial&id=$row[id]'>View</a></b></center></td>
</tr>
<tr>
<td colspan='2'><hr /></td>
</tr>
";
}
echo "</table>";
}
}
else
{
echo "Please give me a category ID!";
}
break;
case "viewtutorial":
ETC.....
any help guys?
this is what the url should look like when finished:
Code:
?id=t&page=tutorials&action=viewcategory&id=1
PM me for both full codes.
Bookmarks