Ad block is installed and active. Please support us by disabling it.
HomeSaturday, October 21, 2017, 10:36:22
2

PHP/MySQL Bookmarklet - PHP Tutorial

Tuesday, February 10, 15, 14:50:49, 3 Yaers Ago Via wain, Hits: 3484
PHP/MySQL bookmarklet, bookmark current page, PHP/MySQL tutorial.
1. Import SQL file into your database.
import.sql
Code:
CREATE TABLE `weburl` (
`id` int(11) NOT NULL auto_increment,
`url` text collate utf8_unicode_ci,
`text` text collate utf8_unicode_ci,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


2. Create a Connection to a MySQL Database.
config.php
Code:
<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'mypassword';
$dbname = 'mydbname';
$conn=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conn) :
die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $conn);
if(!$db) :
die ('Cant connect to database : ' . mysql_error());
endif;
?>


Submit Form.
submit.php
Code:
<?php
include('config.php');
@$gettitle = $_GET['title'];
@$gettitle = addslashes ($gettitle);
@$geturl = $_GET['url'];
@$geturl = "http://" . $_GET['url'];
@$geturl = addslashes ($geturl);
if(isset($_POST['submit']))
{
$url = $_POST['url'];
$title = $_POST['title'];
$result = mysql_query("INSERT INTO weburl (url,text)
VALUES ('$url','$title')")
or die(mysql_error());
echo "Ok";
}else{
?>
<head>
</head>
<form action="submit.php" method="post">
<input type="hidden" name="url" value="<?php echo $geturl ?>">
<input type="text" name="title" value="<?php echo $gettitle ?>">
<input type="submit" value="Submit" name="submit">
</form>
<?php } ?>


4. Select From MySQL
mylinks.php
Code:
<?php
////make a MySQL connection
include('config.php');
//get url, text from the webpage table
//..or..*=select everything from the table weburl
$result = mysql_query("SELECT url, text FROM weburl
order by id desc")
or die(mysql_error());
while($myrow = mysql_fetch_assoc($result))
{
echo "<a href=\"$myrow[url]\">$myrow[text]</a><br />";
}
?>



Bookmarklet Link Code - Google Chrome Bookmarks Bar
Code:
Drag this link: <a href="javascript:(function(){f='http://www.example.com/submit.php?url='+location.href.replace(/http?:\/\//i, '')+'&title='+encodeURIComponent(document.title)+'ยต=451397693h74456&';a=function(){if(!window.open(f+'noui=1&jump=doclose','sharer321','location=no,links=no,scrollbars=no,toolbar=no,width=660,height=200'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()">Bookmark on Example.com</a> up to your Bookmarks Toolbar.






Sign In

Sponsor

Related

Contact Us PHP Form 1.1.

A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

PHP Redirect

Header (location) redirect must be processed before any output to the browser.

Contact Us 2.0. :: PHP Form

Version 2.0. - A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

Process Form Data with Jquery

jQuery, Process form data

PHP str_replace

str_replace - This function returns a string or an array with all occurrences of search in subject replaced with the given replace value

Site Recommendation

This script will allow your visitors to recommend your site to their friends.

Block Visitors From Specific IP Address

Learn How To Restrict Users From Different IP Addresses.

Jquery - Formatting International Phone Numbers

How to format international telephone numbers with jquery

How to insert new line (IP Address) with fwrite

How to insert new line (IP Address) with fwrite, Get IP address and write to file.

GuestBook PHP Script

Allow visitors to leave messages on your site. It features easy install, admin notification, and control panel to remove unwanted entries.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.