HomeTuesday, May 23, 2017, 20:31:56
2

PHP/MySQL Bookmarklet - PHP Tutorial

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

Sitemap

phpForm.net Website Sitemap

Advanced Contact Form - PHP Script

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

Preg_Match - PHP Form Validation

PHP form validation with preg_match

Getimagesize

Getimagesize function will determine the size of any given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag and the correspondant HTTP content type.

PHP $_SESSION

Session_start creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

PHP Forms

FREE PHP forms

PHP Form Basic

PHP Form - PHP form basic, Requirement(s): PHP Server

Filter Words in PHP - PHP Tutorial

Filter bad words in PHP, requirement(s): PHP server

Contact Us 2.0. with HTML Page and Pop Up Frame

This is the same Contact Us 2.0. that is in this forum, But I have added more options to this script and a html page with a very nice pop Up frame that DONT get block by any pop Up software. Many websites use this type of script to bypass the blocking…

Inserting form data in MySql table

Inserting form data in MySql table with PHP
About Author

wain

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