Has anyone got any ideas why this doesnt display the links, after someone has entered them in the form?
addlinks/index.php:
[code=php]
<?php
//** Include library
include(“library.inc.php”);
//** Shorten names
$name = $website_name;
$url = $website_url;
//** If confirmed from confirm.php then write to file
if ($confirm)
{
//** Create website link
$website_link = ” <a href=”” . $confirm_website_url . “”>” . $confirm_website_name . “</a> “;
//** Append link to file
$file_pointer = fopen(DATA_FILE, “a”);
fwrite($file_pointer, $website_link . “<br>n”);
fclose($file_pointer);
}
//** Both variables are empty so show main page
if ($name == “” && $url == “”)
{
include(“form.tpl”);
//** Display links and exit
$file_pointer = fopen(DATA_FILE, “r”);
$file_contents = fread($file_pointer, filesize(DATA_FILE));
fclose($file_pointer);
link_table($file_contents);
exit;
}
//** If name field not filled out
elseif ($name == “” && $url !== “”)
error(“You must enter a website name.”);
//** If url field not filled out
elseif ($url == “” && $name !== “”)
error(“You enter a website URL.”);
//** If < or > found in name
elseif (check_for_html($name))
error(“Invalid character < or > in website name.”);
//** If < or > found in url
elseif (check_for_html($name))
error(“Invalid character < or > in website URL.”);
//** If invalid url
elseif (strrpos($url, “http://”) !== 0 || !strstr($url, “.”))
error(“Invalid website URL”);
//** Check for long url
elseif (strlen($url) > 100)
error(“Website Url contains too many characters. 99 characters max.”);
//** Check for long name
elseif (strlen($name) > 35)
error(“Website name contains too many characters. 35 characters max.”);
//** If show confirm from form.tpl
elseif($show_confirm)
{
//** Check for existance of link in data file if so give error
$file_pointer = fopen(DATA_FILE, “r”);
$file_contents = fread($file_pointer, DATA_FILE);
fclose($file_pointer);
if (strrpos($file_contents, $url) > 0 || strrpos($file_contents, $name) > 0)
{
error(“That link already in the data file”);
exit;
}
include (“confirm.php”);
exit;
}
?>
Library.inc.php:
[code=php]<?php
define(ADMIN_VALIDATE, FALSE);
define(DATA_FILE, “links.dat”);
//** Displays error
function error($error_message)
{
echo “<table width=”100%” height=”100%” cellpadding=”0″>
<tr>
<td width=”100%” height=”100%” align=”center” valign=”top”>
$error_message
</td>
</tr>
</table>”;
}
//** Creates the table to put the links in
function link_table($link_string)
{
echo “<table>
<tr>
<td width=”290″>
$link_string
</td>
</tr>
</table>”;
}
//** Checks for < or >
function check_for_html($text)
{
if (strstr($text, “<“) || strstr($text, “>”))
return true;
else
return false;
}
?>
confirm.php
[code=php]<table class=”tableRows” width=”200″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td>
<table class=”option” cellpadding=”0″ cellspacing=”0″><tr><td width=”28″> <img src=”<?=$snippet_theme?>/img/links.gif” alt=”+”></td><td>Confirm-A-Link…</td></tr></table>
</td>
</tr>
</table><br />
<strong>Name: </strong><?php echo $name ?><br />
<strong>URL: </strong><?php echo $url ?><br />
<form action=”” method=”post”>
<input type=”hidden” name=”confirm” value=”TRUE”>
<input type=”hidden” name=”confirm_website_name” value=”<?php echo $name ?>”>
<input type=”hidden” name=”confirm_website_url” value=”<?php echo $url ?>”><br />
<input type=”submit” value=”Confirm Link” class=”submit”>
</form>
snippets/index.php
[code=php]
} elseif(isset($_GET[‘resources’])) {
include ‘resources.php’;
//** Display links and exit
$file_pointer = fopen(DATA_FILE, “r”);
$file_contents = fread($file_pointer, filesize(DATA_FILE));
fclose($file_pointer);
link_table($file_contents);
exit;
resources.php
[code=php]include ‘addlinks/library.inc.php’; //for add a link menu