How do i add a bookmarks script to my website www.rn1162.com
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<div class="container">
<div class="span2"> <!-- Sidebar content -->
<h3>Bookmarks</h3>
<?php
$filename = 'bkm_data.txt';
if(file_exists($filename))
{
$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
if (!empty($data))
{
foreach($data as $key => $val)
{ // Iterates through the array
echo '<button type="button" class="btn btn-link"><a href="'.$val.'" target="_blank">'.$key.'</button><br />'; // Writes an href button for each key.
}
}
}
?>
</div> <!-- END Sidebar content -->
</div>
<?php
session_start();
$array = array();
if(isset($_POST['Name']) && $_POST['Name'] != "")
{
$name = htmlspecialchars($_POST['Name'], ENT_QUOTES);
$url = htmlspecialchars($_POST['URL'], ENT_QUOTES);
$filename = 'bkm_data.txt';
if(file_exists($filename))
{
$array = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
}
$array[$name] = $url;
ksort($array);
$res = fopen("bkm_data.txt","r+"); // Opens a resource
$string = serialize($array); // Sets a variable to identify the serialized array
$write = fwrite($res,$string); // Writes it to the file
@fclose($res);
}
//unset($array[$name]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="CMS to create Bookmarks">
<meta name="author" content="Jim Ord">
<link rel="icon" href="favicon.ico">
<title>Bookmarker</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="row">
<div class="span12"> <!-- form content -->
<h3>Add a Bookmark</h3>
<form name="Bookmark" action="" method="post">
<label>Bookmark Name <input type="text" id="Bookmark" name="Name" required="required" /></label>
<label>Bookmark URL <input type="text" id="Bookmark" name="URL" placeholder="http://" required="required" /></label>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div> <!-- END form content -->
<div class="span2"> <!-- Sidebar content -->
<h3>Bookmarks</h3>
<?php
$filename = 'bkm_data.txt';
if(file_exists($filename))
{
$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
if (!empty($data))
{
foreach($data as $key => $val)
{ // Iterates through the array
echo '<button type="button" class="btn btn-link"><a href="'.$val.'" target="_blank">'.$key.'</button><br />'; // Writes an href button for each key.
}
}
}
?>
</div> <!-- END Sidebar content -->
</div>
</div>
</body>
</html>
Did you do this?Finally, you need to create an empty .txt file - called bkm_data.txt
I'll need to see the full script please Russ - php included ...Warning: fopen(bkm_data.txt) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\5711000\html\bookmarks.php on line 18
here is the link again:<?php
session_start();
$array = array();
if(isset($_POST['Name']) && $_POST['Name'] != "")
{
$name = htmlspecialchars($_POST['Name'], ENT_QUOTES);
$url = htmlspecialchars($_POST['URL'], ENT_QUOTES);
$filename = 'bkm_data.txt';
if(file_exists($filename))
{
$array = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
}
$array[$name] = $url;
ksort($array);
$res = fopen("bkm_data.txt","r+"); // Opens a resource
$string = serialize($array); // Sets a variable to identify the serialized array
$write = fwrite($res,$string); // Writes it to the file
@fclose($res);
}
//unset($array[$name]);
?>
<!DOCTYPE html>
Bookmarker
Add a Bookmark
Bookmark Name
Bookmark URL
Submit
Bookmarks
<?php
$filename = 'bkm_data.txt';
if(file_exists($filename))
{
$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
if (!empty($data))
{
foreach($data as $key => $val)
{ // Iterates through the array
echo '<a href="'.$val.'" target="_blank">'.$key.'
'; // Writes an href button for each key.
}
}
}
?>
No problem, I don't think that the file permissions are the problem. If you can change the relative address of the file to an absolute hyperlink address it should solve it - i.e. if you change this lineI do not have permission to change file permissions on godaddy at all.
$filename = 'bkm_data.txt';
$filename = 'http://www.rn1162.com/bkm_data.txt';
Thanks<?php
session_start();
$array = array();
if(isset($_POST['Name']) && $_POST['Name'] != "")
{
$name = htmlspecialchars($_POST['Name'], ENT_QUOTES);
$url = htmlspecialchars($_POST['URL'], ENT_QUOTES);
$filename = 'http://www.rn1162.com/bkm_data.txt';
if(file_exists($filename))
{
$array = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
}
$array[$name] = $url;
ksort($array);
$res = fopen("bkm_data.txt","r+"); // Opens a resource
$string = serialize($array); // Sets a variable to identify the serialized array
$write = fwrite($res,$string); // Writes it to the file
@fclose($res);
}
//unset($array[$name]);
?>
<!DOCTYPE html>
Bookmarker
Add a Bookmark
Bookmark Name
Bookmark URL
Submit
Bookmarks
<?php
$filename = 'http://www.rn1162.com/bkm_data.txt';
if(file_exists($filename))
{
$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array.
if (!empty($data))
{
foreach($data as $key => $val)
{ // Iterates through the array
echo '<a href="'.$val.'" target="_blank">'.$key.'
'; // Writes an href button for each key.
}
}
}
?>