PHP Tutorial : Write text and convert into image

The base usage in my mind when I write this tutorial to convert text into image with php is to write email into images dinamically to avoid spammers collecting such addresses from the internet.

To run such a script you must have GD library installed. We’ll take parametres via GET and merge into image:

<?php

if(!isset($_GET['text']))
{
die("No text provided");
}
header ("Content-type: image/png");
$textToConvert = $_GET['text'];
$font   = 4;
$width  = ImageFontWidth($font) * strlen($textToConvert);
$height = ImageFontHeight($font);
$im = @imagecreate ($width,$height);
$background_color = imagecolorallocate ($im, 255, 255, 255); //this means it's white bg
$text_color = imagecolorallocate ($im, 0, 0,0);//and of course black text
imagestring ($im, $font, 0, 0,  $textToConvert, $text_color);
imagepng ($im);
?>

Save this as textToImage.php and then when you want to create the image and read text do it like :

<img src="textToImage.php?text=emailAddress@emailProvider.com">

Tags: , , , , ,

PHP Tutorial : Get Browser Name & It’s Capabilities

To get browser name just use next thing :

<?php
print $_SERVER['HTTP_USER_AGENT'];
?>

And for all the features of browser user :

<?php
print_r(get_browser(null, true));//null for user agent &amp; true to return array

?>

Tags: , , , , , , ,

Ventrilo Server Hosting

Ventrilo is a voice over IP program that allows multiple people to communicate with each other over an internet connection. You have a choice of audio codecs like Speex and GSM, Ventrilo is based on the client-server model, the client will reside on your computer and the server will relay all of the data from the other clients to your computer. Ventrilo server hosting is fairly affordable, starting at $2.91 per month for 10 users.

Ventrilo is a great utility for development teams who like to keep in touch without having to deal with IM programs.

Tags:

It stuff : PHP ByPass Captcha Code

Sounds exactly what you want ? Are you damn curious about how to bypass captcha with php? Me too, and, I’ve found a very interesting set of functions which does that for you. Go to http://pastebin.com/f1560d747

You’ll see it’s requesting an api key you may get right here http://www.captchakiller.com/

Good Luck!

I have not tested it yet, you may let me know how is it by commenting!

Tags: , , ,

PHP Tutorial : Country list array

In my point of view, a very usefull and common thing we need when we build for example a membership site it’s country list array. I will do it within next function then will show how to use it :

Click here to get the function

And here’s how to use it for example to generate a select (drop down) with options to list countries:

<?php
$countryList = countryArray();

print "<select name=\"countryList\">";

foreach($countryList as $simbol => $country) {

print "<option value=\"$simbol\">$country</option>\n";
}

print "</select>";
?>

Simply usefull!

Tags: , , , , , , ,

PHP Tutorial : List function

Beeing surprised that I didn’t write here about this “cute” php function called list(). I like it a lot, it’s like the extract() function in some way if you remember.

The list() php function will assign variables in one shot to strings from arrays.

<?php
//here's the php array

$countingArray = array(1,2,3);
//here, the list function will convert 1 to $one variable, 2 to $two and 3 to $three

list("one", "two", "three") = $countingArray;

print "I am counting $one, errr I think it comes $two, and lastly $three";
//should print I am counting 1, err....comes 2 and lastly 3

?>

Tags: , , , ,

How Shared Web Hosting is a Batter Option?

A web server is a device that allows you to present your website over the internet. Only a few companies afford to pay a huge amount to encompass an entire web server, named as dedicated web hosting. The other small and medium sized organizations can not afford such big sums. The option of shared or cheap web hosting is always open for such small scale companies.
Understanding shared hosting one can reveal that more than one websites can be hosted on a single server on which web space on the hard disc is divided among all the websites hosted on that server. It means that a number of websites use the same server to save their data. There is some necessary information that everyone must collect before choosing a shared or cheap web hosting. Like, is the shared web hosting worthwhile? What is the maximum number of websites that can use a hard drive? Are the server activities affected by increasing the number of hosted websites?
There is no limit of hosted websites on a single server, theoretically. As the web servers cost very high, everyone would like to host as many site as they can. This is actually beneficial for the web hosting providing company to host a large number of sites on a single server; however, for the website owner’s point of view it is not a good practice to host the website on a server that contains a lot of websites. Some of the experienced webmasters believe that it less depend on the number of websites, there is a possibility that only a single large website may occupy all the CPU and RAM space. So, there is a need to know which websites are hosted on that shared web server on which you are going to host your website.

Tags: , ,

PHP Tutorial : Results Pagination

A very usefull and common subject : php pagination. You need this when you have a lot of entries in the database and don’t want to show them in a single page, here comes the results pagination in php. This works pretty simple, not that complex : firstly we calculate the total ammount of entries, then the numbers of page needed to show everthing, and, of course, how many results per page. Finaly, we’ll print out the entries and links for next, previous and page numbers.

//include database connection (check previous posts to get this one)
include('dbConnection.php');
//get the number of total rows
$query = "SELECT * FROM TableName";
$result = mysql_query($query);
// Number of records found
$num_record = mysql_num_rows($result);
// Number of results per page
$display = 5;
if(isset($_GET['page']) {
$currentPage = $_GET['page'];
}else{
$currentPage = 1;
}
//last page
$lastPage = ceil($num_record/$display);
//limit in the query thing
$limitQ = 'LIMIT ' .($currentPage - 1) * $display .',' .$display;
//normal query and print results
$query = "SELECT * FROM TableName $limitQ";
$result = mysql_query($query);
//here you do your loop like
while($row=@mysql_fetch_object($result)) {
print "$row->FieldName";
}
//pagination navigation (links)
//previous
if ($currentPage == 1) {
print "Prev ";
} else {
print "<a href=pagename.php?page=1>First page</a> ";
$previousPage = $currentPage-1;
print "<a href=pagename.php?page=$previousPage>Previous</a>";
}
print " { Page $currentPage of $lastPage } ";
//for next pages links
if ($currentPage== $lastPage) {
print "Next last";
} else {
$nextPage = $currentPage+1;
print " <a href=pagename.php?page=$nextPage>NEXT</a> ";
print " <a href=pagename.php?page=$lastPage>LAST</a> ";
}
?>

Now you can use this pagination to split your mysql results into multiple webpages!

Tags: , , , , , , , , , , ,

Feedburner Feed

Hi,
This is a request for people reading my feed or who already subscribed.
Please use the feedburner feed so I will be able to see how many guy’s are following.

FEEDBURNER URL :
http://feeds2.feedburner.com/crivionweb/kRHa

Tags:

PHP Tutorial : Membership script - Users Logout

Final step and the most easiest part is now users logging out. Just build a page called logout.php and put a link to it everywhere you want to give the option to users to logout & here’s the function:

<?php
function logoutUser() {
session_unset();
session_destroy();
header("Location: homePage.php");
exit();
}
//here's how you put it in action


logoutUser();
?>

Extraordinary,

Now you know how to build a complete membershipt script/site with php including registering module, logiging in & check this thing, and of course users logout module.

Tags: , , ,

« Previous entries