<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";

$done = $_POST['done'];
$id = $_POST['id'];
$name = $_POST['name'];
$targeturl = $_POST['targeturl'];



if( isset($_SESSION["ulogin"]) ) {

    include("navigation.php");
    include("../banners2.php");
    echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
    if ($done == "YES") {
	
	

		if (empty($name)){

       		?><p>No name entered. Click <a href=addtopnav.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;

    	}

		if (empty($targeturl)){

       		?><p>No url entered. Click <a href=addtopnav.php>here</a> to go back<p> <?
       		include "../footer.php";
       		exit;

    	}
		
		$name = dbput($name);
		$targeturl = dbput($targeturl);
		

    	$query = "update topnav set name='$name', targeturl='$targeturl', added=1, status=0 where id=".$id;
    	$result = mysql_query ($query)
	     	or die ("Query failed");

    	?>

      		<p><center>Your Top Navigation Link has been placed in the queue for Admin appproval.<br><a href="advertise.php">Click here</a> to go back.</p></center>

    	<?

    }
    else {

    	$query = "SELECT * FROM topnav where added=0 and userid='".$_SESSION[uname]."' limit 1";
		$result = mysql_query ($query)
			or die ("Query failed");

    	while ($line = mysql_fetch_array($result)) {

            $id = $line["id"];
            $name = dbget($line["name"]);
            $targeturl = dbget($line["targeturl"]);

            ?>


              <br><center><H2>ADD TOP NAVIGATION LINK</H2>Text for link cannot be longer than 20 characters including spaces. <BR><BR><font color= #FF0000><b>NOTE:</b> Please Use Cloaked URLs Only! Your Regular Affiliate URL will <b>NOT</b> Work!</font><br><br>
				<font style="font-weight: bold">
              <form method="POST" action="addtopnav.php">
              Text:<br>
              <input type="text" name="name" maxlength="20"><br>
              Url:<br>
              <input type="text" name="targeturl" value="http://"><br>
              <input type="hidden" name="id" value="<? echo $id; ?>">
              <input type="hidden" name="done" value="YES">
			  <p>Please double check your Top Navigation Link before you save.<br>It cannot be edited once submitted!</p>
              <input type="submit" value="Save">
              </form></center>
            <?

    	}

    }

    echo "</td></tr></table>";

  }

else

  { ?>


  <p>You must be logged in to access this site. Please <a href="../index.php">click here</a> to login.</p>

  <? }


include "../footer.php";

mysql_close($dblink);

?>