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!

Posted in It Stuff | Tagged , , , | Leave a comment

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!

Posted in Usefull PHP | Tagged , , , , , , , | Leave a comment

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

?>
Posted in Usefull PHP | Tagged , , , , | Leave a comment

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.

Posted in It Stuff | Tagged , , | Leave a comment

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!

Posted in Complete Scripts | Tagged , , , , , , , , , , , | Leave a comment

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

Posted in It Stuff | Tagged | Leave a comment

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.

Posted in Complete Scripts | Tagged , , , | Leave a comment

PHP Tutorial : Membership script – Users Registration

Hello, I’ve just created a brand new category called Complete Scripts. In this one you will find complete solutions of applications.

The first tutorial is called how to create a membership script with user registration. I will write here a function which will do it! We will have database structure like this :

CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user` varchar(255) NOT NULL,
`pass` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

After this, here is the function to create new users and insert them into database: – first, create a .php page called functions.php

<?php
//Membership Script - Users Registration Function

function registerNewMember($user, $pass) {
$tableUsers = "users";

if(empty($user) || empty($pass)) {
exit();
}else{
$user = addslashes(mysql_real_escape_string($user));
$pass = addslashes(mysql_real_escape_string($pass));
$sql = "insert into $tableUsers values (null, '$user', '$pass')";
$rs = mysql_query($sql);

if($rs)
{
$result = "ok";
}else{
$result = "fail";
}
}
?>

Now we need to create a page with a form where users will type their desired user & pass (please note we need to include database connection file and functions one:

<?php
//include database connection


include('dbConnection.php');
//include functions.php


include('functions.php');
//check if registration form was submitted


if(isset($_POST['sb'])) {
extract($_POST);

if(registerNewMember($username, $password) == "ok")) {

print "You are now registered";
}else{

print "Not able to add new member";
}
}
?>
<form action="" method="POST">
Pickup  a new username : <input type="text" name="username"><br/>
Pikcup a brand new password : <input type="password" name="password"><br/>
<input type="submit" name="sb" id="sb" value="Register me!">
</form>

PS : For database connection please remember here

Posted in Complete Scripts | Tagged , , , , , , , , , | 2 Comments

PHP Tutorial : Write to a file with fwrite

I showed you earlier in a older post how to open and read text contents from a file. Now it’s time to see how to write to a file using php function called fwrite().

<?php
$theFileToWriteTo = "textFile.txt";
$fileHandle = fopen($theFileToWriteTo, 'w') or die("cannot open the text file");
$textToWrite = "First text to write here\n";
fwrite($fileHandle, $textToWrite);
$textToWrite = "Second line to write here\n";
fwrite($fileHandle, $textToWrite);
fclose($fileHandle)
?>

Note that “\n” means new line!

Posted in Basic PHP | Tagged , , , , | 1 Comment