Location: PHPKode > projects > NetLink > netlink_os/add_page.php
<h3>Add a Page</h3>
<?php
if ($submit)
{
extract($_SESSION);
extract($_POST);

$ext=strtolower($add_type);
echo "Extracting Variables...";
$new_file="$add_name.$ext";

if (file_exists("Users/$login/$new_file"))
   echo "<span id='error'>Error</span><br/>\n<br/>Sorry....the file \"$new_file\" exists. Either:\n<ul>\n\n<li>Delete the existing file to overwrite the existing name</li>\n\n<li>Create another name</li>\n\n<li>Edit your current page.</li></ul>\n\n";
else
{   
	if(!($f=fopen("Users/$login/$new_file","w")))
			exit("Unable to open file.");
		while(!feof($f))
		{
			$x=fgets($f);
			echo $x;
			$code="";
			if ($add_type=="HTML")
				$code="&#160;";	
	
			$code.="<!--$new_file created on ";
			$code.=date("l dS of F Y h:i:s A");
			$code.="-->";
	
			echo "\n<br/>\n";
			echo "Justifying and modifying for file creation of $new_file...";
			fwrite($f,($code));
		}
		fclose($f);
		
		#error trap
		touch("Users/$login/$new_file");
		
			
		echo "\n<br/>File Modification: ";
		$mod=date ("m/d/y h:i ", filemtime("Users/$login/$new_file"));
		echo $mod;
		echo "\n<br/><br/>\n<b>File $new_file created in $login's account!</b>";
		echo "<br/><br/>";
		echo "Go ahead and <a href='egap.php?file=$new_file' class='under'>edit this page!</a>";
}
include("options.php");
echo "<hr color='#000000'/>";
}
?>
You can add a page to your account just by filling in the below form and clicking on <b>Add Page</b>!
<br/><br/>
<form method='post' action='?id=add_page'>
<table summary='add'>
<tr>
<td>
Page Name:
</td>
<td>
<input type='text' name='add_name'/>
</td>
</tr>
<tr>
<td>
Page Type:
</td>
<td>
<?php
$host='216.10.20.4';
	$account='kaiba_webmaster';
	$acc_pw='staples1279294';
	$table="kaiba_netlink";
	$dbh=mysql_connect ($host,$account,$acc_pw) or die (mysql_error());
	mysql_select_db ($table); 
	$user=$_SESSION['login'];
	$sql="SELECT edit FROM Accounts WHERE Username='$user'";
	$rs=mysql_query($sql,$dbh);
	$row=mysql_fetch_array($rs);
	
	$edit=$row['edit'];
	mysql_close($dbh);
	
  echo "<select name='add_type'>";
  
  if ($edit!='Advanced'){
    $type=array("HTML","TXT");
    $type_exp=array("Basic Web Page","Plain Text File");
  }
  else{
    $type=array("HTML","CSS","JS","PHP","XML","XSL","SVG","TXT");
    $type_exp=array("Basic Web Page","Stylesheets","Website Effects","Server-Side Scripting Language","Data Storage","Data Display [w/ XML]","Scalable Vector Graphics [Experts Only!]","Plain Text File");
  }
	$i=0;
	for ($i==0; $i<=count($type_exp)-1; $i++)
	{
	  echo "<option value='$type[$i]'>&#42;.$type[$i] ($type_exp[$i])</option>\n";
	};

?>
</select>
</td>
</tr>
</table>
<input type='submit' name='submit' value='Add Page'/>
</form>
Return current item: NetLink