HomeMonday, June 26, 2017, 10:23:23
2

PHP/MySQL Bookmarklet - PHP Tutorial

Tuesday, February 10, 15, 14:50:49, 2 Yaers Ago Via wain, Hits: 2804
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 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.

PHP Links Script 1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

PHP $_POST Function

Collect values from a form sent with method post

FeedBack Form with Captcha

It allows your visitors to send you an email directly from your website.

Captcha V2 - Free PHP Script

PHP Captcha protection image Version 2, - Requirement(s): PHP Server, GD Library

Site Recommendation

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

Advanced Contact Form - PHP Script

Advanced Contact Form with email and form field validation. Features: HTML Output(Response), Captcha Image.

HTML Button Generator

This script will allow your visitors to create HTML Buttons online. To use the "html button generator" script completely free , the "powered by" link at the bottom of the pages must stay intact.

Captcha V1 - Free PHP Script

An anti-spam form protection image written in PHP, Version: 1.1.

Email to Friend - PHP Script

This form allows your visitors to suggest your site to a friend. It features an HTML email format and an admin notification email.
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.