Ok, modified but im still having problems.
The below script is suppost to add a link to a list of links when a page visited include the addlink file. However no links are displayed, but their are no errors either. I am very unexperienced, i am in need of some help, thanks.
heres the modified versions.
Top.php, shows the links:
[code=php] <?PHP
$connection = mysql_connect("localhost", "a", "a") or die( mysql_error() );
mysql_select_db("a") or die( mysql_error() );
if(isset($_POST['link']) && is_array($_POST['link']))
{
foreach($_POST['link'] as $id => $checked)
{
if(!empty($checked))
{
$sql = "DELETE FROM sidekik
WHERE id = $id
LIMIT 1";
$result = mysql_query($sql);
if ($result)
{
Header("Location: {$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}");
}
}
}
}
?>
<div align="center"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>S</strong>ide<strong>K</strong>ik<em><font size="1">
By <a href="http://www.22pixels.com">22Pixels</a></font></em></font> </div>
<?PHP
$ip = $_SERVER["REMOTE_ADDR"];
$sql = "SELECT *
FROM sidekik
WHERE ip = '$ip'
ORDER BY time DESC";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
print "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
while ($row = mysql_fetch_assoc($result)) {
print "<a href=\"{$row['link']}\" target=\"sidekik\">{$row['name']}</a> <input type=\"checkbox\" name=\"link[" . $row['id'] . "]\">";
}
"</form>";
}
?><input type="submit" value="Delete" name="submit">[/code]
Addlink.php shows the links:
[code=php] <?PHP
$connection = mysql_connect("localhost", "a", "a") or die( mysql_error() );
mysql_select_db("a") or die( mysql_error() );
$link = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$ip = $_SERVER["REMOTE_ADDR"];
$sql =
"SELECT name FROM sidekik
WHERE ip = '$ip'";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
$sql2 =
"INSERT INTO sidekik (ip, link, name, time)
VALUES ('$ip', '$link', '$name', NOW())";
$result2 = mysql_query($sql2);
}
?> [/code]
The page that would be added when visited.
[code=php] <?php
$name = "Index";
include('../addlink.php');
?> [/code]
<BODY STYLE="background-color:transparent">
<font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">Index</font>
Sorry, I am very unexperienced in PHP. This script was written for me, but the author gave up and hasn't been online too much.