Tuesday, May 31, 2016

If Condition Meeting 6

Now we learn on "IF Ststement/Condition". In this example we still apply 2 files (pages) so that we can remember the previous lesson. Please pay attention to the single "if condition" below:

<html>

<head>
<title>Conditions</title>
</head>
<body>
<h3>IF Condition</h3>
<br>
Fill in a name and a exams mark[0-100] below:
<form action="seven.php" method="post">
<pre>
Nama : <input type="text" name="usrname" size="30" maxlength="30"><br><br>
Nilai : <input type="text" name="mark" size="3" maxlength="3"><br><br>
<input type="submit" value="Send Soon!">
</pre>
</form>
</body>
</html>

save the above file as six.php
Then create a script as a new file and save it as seven.php like below:

<html>
<head>
<title>Seven</title>
</head>
<body>
<h3>Thank you for entering your data</h3><br>
<h4>The marks result is:</h4>
<br>
<?php
$usrname = $_POST[usrname];
$mark = $_POST[mark];
$result = "Not Passed";
if ($mark >= 60){
$result = "Passed";
}
print("<h3>
$usrname is <font color=red><b>$result</b></font>
</h3>");

?>
</body>
</html>

Then open your browser and point to the six.php and see the result. It should show that the mark greater than or equal to 60 is "passed", if not it s "not passed".
The logic is, if the condition is "true" then the statement inside the { } bracket is executed if "false" it is not executed.

Hazrat Isa a s By Hafiz Muhammad

Hazrat Isa a.s By Hafiz Muhammad 

Hazrat Isa a.s free download book
Hazrat Isa a.s  A Prohphet of Allah . In this Book you will Read all story of Hazrat Isa a.s . I am daily basis posting a such a books so that people can read history of humanity. So Download This
Download

Gallery Generator PHP Script Generate Picture Galleries On Your Web Site

Gallery Generator is the perfect and easy solution to generate picture galleries on your web site. It is all template based so just upload your templates and when you choose a template the script will automatically put the images where they are supposed to go.

Requirements

  •     PHP 5+ -http://www.php.net
  •     GD Library – http://www.libgd.org

Installation
  •     Open config.inc in the main folder and modify the settings to your liking
  •     Modify templates to suit your needs / design in the templates directory
  •     You may add new templates to the directory (they will show up automatically in the admin form)
  •     Upload to your server
  •     CHMOD the galleries directory and give it write access (this is where your galleries will be created)
  •     NOTE: You may want to limit access to your script directory by using .htaccess or other methods. If you do this however, make sure when you change settings in config.inc that you don’t place your gallery pages inside of this protected area unless you want it that way.
Download Gallery Generator PHP Script

Financial Class

This class is made by Enrique Garcia to move excel functions into php class. This is very powerful to help develop web based financial system. The functions comprise FV (Future Value), PV (Present Value), PMT (Payment), NPER (Number of Periode), etc.

This class can be downloaded from phpclass.com or here (12kb) including an example file. 

User Registration and Login Script with PHP and MySQL

In this tutorial we will discuss about how to create user registration and login management system with PHP and MySQL in simple procedural way. user registration and login system is most important thing for any kind of web applications and session plays important role in this type of system, for that we have to use session, In this tutorial, we are going to use PHP sessions to keep user login status, here is live demo of this script or you can also download this script, so how to do it let’s see in detail.
User Registration and Login Script with PHP and MySQL
Read more »

Monday, May 30, 2016

Obfuscating php codes

Sometimes we may want to obfuscate our php scripts so that it s no longer human-readable. We can use trasher class freely downloaded from phpclasses.org or you can download here (3kb including example files).

Below is the example of how to use it (before and after obfuscated):

test.php (script which will be confuscated)
<?php
$x = 5;
$y = 10;
$z = $x * $y;
echo ("X * Y = $z");
 ?>

sample.php (script which will confuscate test.php)
<?php 
// include the phptrasher class
require_once(phptrasher.class.php);
// create a new object 
$phptrasher = new phptrasher();
// initialize the class
$phptrasher->initialize();
// setup the class
$phptrasher->removecomments = true;
$phptrasher->removelinebreaks = true;
$phptrasher->obfuscateclass = true;
$phptrasher->obfuscatefunction = true;
$phptrasher->obfuscatevariable = true;
// get the obfuscated code
$obfuscated = $phptrasher->trash(test.php);
// print the formatted code in a beautiful way
highlight_string($obfuscated);
?>

run sample.php to get obfuscated codes of test.php

test1.php (after confuscated)
<?php $_ccc819a68916c3ef4fd822abb9366846 = 5; $_9870ddd74d75773009cf509800565c6f = 10; $_b7739f51732251c6470ac18757649a94 = $_ccc819a68916c3ef4fd822abb9366846 * $_9870ddd74d75773009cf509800565c6f; echo ("X * Y = $_b7739f51732251c6470ac18757649a94"); ?>



Islam Ki Sachai Aur Science Ke Iterafaat


Islam Ki Sachai Aur Science Ke Iterafaat

Islam book in urdu pdf objection of sciene
Islam Ki Sachai Aur Science Ke Iterafaat Interesting Book  and answer of science Objection on Islamic Rules.



PHP Data Update and Delete Using OOP

This tutorial is continuation of my previous tutorial Data Insert and Select using OOPs, In this tutorial i will show you that how to use PHP with OOPs concept for Data Update and Data Delete of MySql, it's so easy to learn, have a look.


Read more »

Free Website Directory PHP Script

Build a complete website directory in just minutes. No need for technical skills, it cant get any easier!.

Features

  • Fast and easy installation. Build a whole website in minutes.
  • Multi-level category structure with unlimited number of categories.
  • Integrated search engine.
  • Easy management. Add/edit/delete/move categories and/or listings with one click.
  • Easy customization. Change the layout by just editing the template files of the script.
  • Build a human-edited directory where users suggest urls and you accept/them rejected.
  • IP banning in order to avoid spam and bad uses of the directory.

Download Website Directory PHP Script

DateClass and DateSpanClass

This file, dateclass.php, consists of two classes, namely, DateClass and DateSpanClass.

DateClass allows you to add a period to a date. You can also retrieve periods such as begin/end of month, begin/end of week, and begin/end of quarters.

DateSpanClass allows you to determine the span between two dates. The span can be a wide variety of different kinds of periods including year, month, week, weekdays, & quarters.

These classes are written by Steve Powell and can be downloaded from phpclasses.org oe from here (60 kb).



Sunday, May 29, 2016

Friendly Captcha

This package can be used to implement CAPTCHA validation using text with math expression.

There is a base class that can display a text message to tell the user what he needs to input.

A math subclass generates an expression with a random math operation between two number values.

The user must enter the result of the operation to pass the CAPTCHA validation. The correct answer is stored in session variables for posterior validation.

All files are written by Chris Hepner.

You can download it here (19kb)


Hazrat Nooh a s History Tareekh in Urdu

hazrat nooh life book in urdu
Hy Friends, I am come back once again after a long time and bring a new book for you title is Hazrat Nooh a.s written by Aslam Rahi in PDF format.


Ajax Registration Script using jQuery with PHP and MySQL

This tutorial will show you how to create Ajax Signup form with jQuery using PHP MySQL and PDO. this will also guide creating a simple registration form using BootStrap, in most of websites you might have seen a registration form which accepts data from users and store into MySQL database without page refresh, this tutorial will also cover an important jQuery Validation part, proper validation using jQuery and database connectivity using PHP, you can look at live demo and try it yourself from the given download link, let's take a look.
Ajax Registration Script using jQuery with PHP and MySQL
Read more »

Text Ad PHP Script

This is a simple & straight-forward text ad script. This script was originally created to administrate the same copies of text/html in multiple web sites from a centralized administration area. The format of ads is free-format style. You can place any text and html code. If you want to display/administrate the same ads or same text/html snippets over multiple web sites, this script will greatly make your life easier.


Download Text AD PHP Script

Returning User Defined Function

A function can return a value using the return statement in conjunction with a value. The return statement stops the execution of the function and sends the value back to the calling code.

Example: creates a function that returns the sum of two numbers.

<?php
function multiply($firstnum, $secondnum) {
$result = $firstnum * $secondnum;
return $result;
}
echo multiply(9,5);
//will print "45"
?>

Put these lines into a text file called multiply.php and place this file in your web server document root. When you access this script through your web browser, it produces the following:
45

Notice in line 2 that multiply() should be called with two numeric arguments (line 6 shows those to be 9 and 5 in this case). These values are stored in the variables $firstnum and $secondnum. Predictably, multiply() multiplies the numbers contained in these variables and stores the result in a variable called $result.

The return statement can return a value or nothing at all. How we arrive at a value passed by return can vary. The value can be hard-coded:
return 4;

It can be the result of an expression:
return $a/$b;

It can be the value returned by yet another function call:
return another_function($an_argument);


Saturday, May 28, 2016

Safe Upload

This class is made by Ahmed Selim Refaat Ahmed and can be used to process files uploaded via Web forms.

It checks a given uploaded file and performs several checks before processing it like: checking the file name against a black list of banned names, check if the file already exists in a target directory, check whether the file size is not zero nor exceeds and given limit, check the MIME type against a list of accepted types, check the file name extension against a list of accepted extensions.

Then the class processes the file by moving it to a target directory. If it succeeds, the class returns an array with several details about the file.

The package can be downloaded here (3 kb).

AmpJuke Online Music Streaming PHP Script

 Manage and stream your music online to several clients connected through a LAN and/or the internet in php.

AmpJuke  php script will act as your streaming server. Besides online music streaming the script can fetch album covers/images/lyrics automatically using various web services from last.fm and other sources.

Scan+import tags from as many tracks you like, use the favorites as well as a bunch of other personal settings to customize the way AmpJuke operates.

Focus is on easy navigation as well as speed. AmpJuke works well, even on rather old/slow equipment.
If AmpJuke is unknown to you, please take a look at the features and/or the requirements.

The best ? AmpJuke is free ! (GPL license).

Features:

  •     Easy installation (yes, really!).
  •     Scan and import information (tags) from music files to a MySQL-database.
  •     Music files can be stored outside the www-folder in any folder+subfolders.
  •     Automatically send listening statistics to last.fm. No plugin is needed.
  •     Analyse the "fingerprint" (tempo/BPM, energy, danceability etc.) for each and every track within your music collection.
  •     Setup your very own online jukebox and start taking requests.
  •     Upload and download music.
  •     Retrieve and display biographies for artists/performers and albums.
  •     Any mediaplayer that "understand" the .m3u-playlist format, can play the streamed music...or just use the flash player...or a combination.
  •     Retrieve and store album covers automatically and/or try the "Scan metadata" feature.
  •     Random play with many options for "fair" rotation of tracks.
  •     Display related performers using webservice from last.fm.
  •     Stream music from related performers (similar to functionality found @ last.fm).
  •     Manage music using personal favorite lists (tags).
  •     Share favorites with other users.
  •     Downsample (transcode) music in realtime to a lower bitrate using LAME.
  •     Show whats playing right now and whats up next.
  •     Themes, icons and several languages makes the look and feel of AmpJuke a matter of personal preference.
  •     Display lyrics for virtually any song in your collection.
  •     Edit track-, performer- and/or album-information.
  •     Automatically block IP-adresses that fails to authenticate a number of times.
  •     Enable self-registration of users.

Download Online Music Streaming PHP Script

A Simple But Secure PHP Login Script For Newbs

Recently I posted about a Login Script in PHP, but some of our readers emailed me and complained about the Implementation Complexity of the script.Though I still consider that script very secure and one of the best, but still to make the unsatisfied lot a little happy, I am going to share a very very simple and yet very secure PHP Login script with you guys.Hope this script will be easy to understand and implement.

Besides, this script is quite secure, protecting your login form against SQL Injection and XSS attacks.You will also need MySQL database to implement this login script.


First Create a table as shown below:

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` char(64) COLLATE utf8_unicode_ci NOT NULL,
`salt` char(16) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Now create a file common.php which will contain code that is shared between the different parts of your login system.

<?php

// These variables define the connection information for your MySQL database
$username = "dbusername";
$password = "dbpassword";
$host = "localhost";
$dbname = "dbname";

// UTF-8 is a character encoding scheme that allows you to conveniently store
// a wide varienty of special characters, like ¢ or €, in your database.
// By passing the following $options array to the database connection code we
// are telling the MySQL server that we want to communicate with it using UTF-8
// See Wikipedia for more information on UTF-8:
// http://en.wikipedia.org/wiki/UTF-8
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => SET NAMES utf8);

// A try/catch statement is a common method of error handling in object oriented code.
// First, PHP executes the code within the try block. If, at any time, it encounters an
// error while executing that code, it stops immediately and jumps down to the
// catch block. For more detailed information on exceptions and try/catch blocks:
// http://us2.php.net/manual/en/language.exceptions.php
try
{
// This statement opens a connect to your database using the PDO library
// PDO is designed to provide a flexible interface between PHP and many
// different types of database servers. For more information on PDO:
// http://us2.php.net/manual/en/class.pdo.php
$db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);
}
catch(PDOException $ex)
{
// If an error occurs while opening a connection to your database, it will
// be trapped here. The script will output an error and stop executing.
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to connect to the database: " . $ex->getMessage());
}

// This statement configures PDO to throw an exception when it encounters
// an error. This allows us to use try/catch blocks to trap database errors.
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// This statement PDO to return database rows from your database using an associative
// array. This means the array will have string indexes, where the string value
// represents the name of the column in your database.
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

// This block of code is used to undo magic quotes. Magic quotes are a terrible
// feature that was removed from PHP as of PHP 5.4. However, older installations
// of PHP may still have magic quotes enabled and this code is necessary to
// prevent them from causing problems. For more information on magic quotes:
// http://php.net/manual/en/security.magicquotes.php
if(function_exists(get_magic_quotes_gpc) && get_magic_quotes_gpc())
{
function undo_magic_quotes_gpc(&$array)
{
foreach($array as &$value)
{
if(is_array($value))
{
undo_magic_quotes_gpc($value);
}
else
{
$value = stripslashes($value);
}
}
}

undo_magic_quotes_gpc($_POST);
undo_magic_quotes_gpc($_GET);
undo_magic_quotes_gpc($_COOKIE);
}

// This tells the web browser that your content is encoded using UTF-8
// and that it should submit content back to you using UTF-8
header(Content-Type: text/html; charset=utf-8);

// This initializes a session. Sessions are used to store information about
// a visitor from one request to the next. Unlike a cookie, the information is
// stored on the server-side and cannot be modified by the visitor. However,
// note that in most cases sessions do still use cookies and require the visitor
// to have cookies enabled. For more information about sessions:
// http://us.php.net/manual/en/book.session.php
session_start();

Now create another file register.php which will allow you to create a user account. 

<?php

// First we execute our common code to connection to the database and start the session
require("common.php");

// This if statement checks to determine whether the registration form has been submitted
// If it has, then the registration code is run, otherwise the form is displayed
if(!empty($_POST))
{
// Ensure that the user has entered a non-empty username
if(empty($_POST[username]))
{
// Note that die() is generally a terrible way of handling user errors
// like this. It is much better to display the error with the form
// and allow the user to correct their mistake. However, that is an
// exercise for you to implement yourself.
die("Please enter a username.");
}

// Ensure that the user has entered a non-empty password
if(empty($_POST[password]))
{
die("Please enter a password.");
}

// We will use this SQL query to see whether the username entered by the
// user is already in use. :username is a special token. We will define
// its value later.
$query = "
SELECT
id
FROM users
WHERE
username = :username
";

// This contains the definitions for any special tokens that we place in
// our SQL query. In this case, we are defining a value for the token
// :username. It is possible to insert $_POST[username] directly into
// your $query string; however doing so is very insecure and opens your
// code up to SQL injection exploits. Using tokens prevents this.
// For more information on SQL injections, see Wikipedia:
// http://en.wikipedia.org/wiki/SQL_Injection
$query_params = array(
:username => $_POST[username]
);

try
{
// These two statements run the query against your database table.
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}

// The fetch() method returns an array representing the "next" row from
// the selected results, or false if there are no more rows to fetch.
$row = $stmt->fetch();

// If a row was returned, then we know a matching username was found in
// the database already and we should not allow the user to continue.
if($row)
{
die("This username is already in use");
}

// This query is used to create a new user record in the database table.
// Again, we are using special tokens (technically called parameters) to
// protect against SQL injection attacks.
$query = "
INSERT INTO users (
username,
password,
salt
) VALUES (
:username,
:password,
:salt
)
";

// A salt is randomly generated here to protect again brute force attacks
// and rainbow table attacks. The following statement generates a hex
// representation of an 8 byte salt. Representing this in hex provides
// no additional security, but makes it easier for humans to read.
// For more information:
// http://en.wikipedia.org/wiki/Salt_%28cryptography%29
// http://en.wikipedia.org/wiki/Brute-force_attack
// http://en.wikipedia.org/wiki/Rainbow_table
$salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));

// This hashes the password with the salt so that it can be stored securely
// in your database. The output of this next statement is a 64 byte hex
// string representing the 32 byte sha256 hash of the password. The original
// password cannot be recovered from the hash. For more information:
// http://en.wikipedia.org/wiki/Cryptographic_hash_function
$password = hash(sha256, $_POST[password] . $salt);

// Here we prepare our tokens for insertion into the SQL query. We do not
// store the original password; only the hashed version of it. We do store
// the salt (in its plaintext form).
$query_params = array(
:username => $_POST[username],
:password => $password,
:salt => $salt
);

try
{
// Execute the query to create the user
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}

// This redirects the user back to the login page after they register
header("Location: login.php");

// Calling die or exit after performing a redirect using the header function
// is critical. The rest of your PHP script will continue to execute and
// will be sent to the user if you do not die or exit.
die("Redirecting to login.php");
}

?>
<h1>Register</h1>
<form action="register.php" method="post">
Username:<br />
<input type="text" name="username" value="" />
<br /><br />
Password:<br />
<input type="password" name="password" value="" />
<br /><br />
<input type="submit" value="Register" />
</form>

Create a login.php which allows user to authenticate. 

<?php

// First we execute our common code to connection to the database and start the session
require("common.php");

// This variable will be used to re-display the users username to them in the
// login form if they fail to enter the correct password. It is initialized here
// to an empty value, which will be shown if the user has not submitted the form.
$submitted_username = ;

// This if statement checks to determine whether the login form has been submitted
// If it has, then the login code is run, otherwise the form is displayed
if(!empty($_POST))
{
// This query retreives the users information from the database using
// their username.
$query = "
SELECT
id,
username,
password,
salt
FROM users
WHERE
username = :username
";

$query_params = array(
:username => $_POST[username]
);

try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
// Note: On a production website, you should not output $ex->getMessage().
// It may provide an attacker with helpful information about your code.
die("Failed to run query: " . $ex->getMessage());
}

// This variable tells us whether the user has successfully logged in or not.
// We initialize it to false, assuming they have not.
// If we determine that they have entered the right details, then we switch it to true.
$login_ok = false;

$row = $stmt->fetch();
if($row)
{
// Using the password submitted by the user and the salt stored in the database,
// we now check to see whether the passwords match by hashing the submitted password
// and comparing it to the hashed version already stored in the database.
$check_password = hash(sha256, $_POST[password] . $row[salt]);
if($check_password === $row[password])
{
// If they do, then we flip this to true
$login_ok = true;
}
}

// If the user logged in successfully, then we send them to the members page
// Otherwise, we display a login failed message and show the login form again
if($login_ok)
{
// Here I am preparing to store the $row array into the $_SESSION by
// removing the salt and password values from it. Although $_SESSION is
// stored on the server-side, there is no reason to store sensitive values
// in it unless you have to. Thus, it is best practice to remove these
// sensitive values first.
unset($row[salt]);
unset($row[password]);

// This stores the users data into the session at the index user.
// We will check this index on the members page to determine whether
// or not the user is logged in. We can also use it to retrieve
// the users details.
$_SESSION[user] = $row;

// Redirect the user to the members page.
header("Location: members.php");
die("Redirecting to: members.php");
}
else
{
// Tell the user they failed
print("Login Failed.");

// Show them their username again so all they have to do is enter a new
// password. The use of htmlentities prevents XSS attacks. You should
// always use htmlentities on user submitted values before displaying them
// to any users (including the user that submitted them). For more information:
// http://en.wikipedia.org/wiki/XSS_attack
$submitted_username = htmlentities($_POST[username], ENT_QUOTES, UTF-8);
}
}

?>
<h1>Login</h1>
<form action="login.php" method="post">
Username:<br />
<input type="text" name="username" value="<?php echo $submitted_username; ?>" />
<br /><br />
Password:<br />
<input type="password" name="password" value="" />
<br /><br />
<input type="submit" value="Login" />
</form>
<a href="register.php">Register</a>

Now create another file members.php which you may protect with your login system. 

<?php

// First we execute our common code to connection to the database and start the session
require("common.php");

// At the top of the page we check to see whether the user is logged in or not
if(empty($_SESSION[user]))
{
// If they are not, we redirect them to the login page.
header("Location: login.php");

// Remember that this die statement is absolutely critical. Without it,
// people can view your members-only content without logging in.
die("Redirecting to login.php");
}

// Everything below this point in the file is secured by the login system

// We can display the users username to them by reading it from the session array. Remember that because
// a username is user submitted content we must use htmlentities on it before displaying it to the user. The
// fact that we retrieved it from a database and not directly from the user does not matter.
?>
Hello <?php echo htmlentities($_SESSION[user][username], ENT_QUOTES, UTF-8); ?>, secret content!<br />
<a href="logout.php">Logout</a>

Now create a logout script logout.php which will enable your user to logout safely.
<?php

// First we execute our common code to connection to the database and start the session
require("common.php");

// We remove their data from the session
unset($_SESSION[user]);

// We redirect them to the login page
header("Location: login.php");
die("Redirecting to: login.php");

?>

Thats all!


I think that the PHP Script is simple enough to be understood and is self explanatory.And its tried and tested as well, so you can straightaway implement this script on your website.If you have any suggestions regarding this script then feel free to comment below.

Besides, if you like our blog and want to receive updates directly in your email, then you can subscribe below and dont forget to activate your subscription.Enjoy!

Cheers!


Switch Statement Meeting 9

"switch" statement is the alternative way to the multiple "if..elseif" conditions and can be shorter way to code than "if..elseif". The regular scripts applying "switch" staement is like this:

switch (expression) {
case result1:
// execute this if expression results in result1
break;
case result2:
// execute this if expression results in result2
break;
default:
// execute this if no break statement has been encountered hitherto
}

a switch statement will inspect expression by expression in a list of expression, and fire only one statement which is a match.

It is important to include a break statement at the end of any code that will be executed as part of a case statement. Without a break statement, the program flow will continue to the next case statement and ultimately to the default statement. In most cases, this will result in unexpected behavior, likely incorrect!

try a script below and save it as eight.php

<?php
$greeting = "morning"; //you may change to "afternoon" or "evening"
switch ($greeting) {
case "morning":
echo "Good morning";
break;
case "afternoon":
echo "Good afternoon";
break;
case "evening":
echo "Good evening";
break;
default:
echo "I dont know what to say but good $mood anyway.";
break;
}
?>

we initialize a variable $greeting with a value "morning". "switch" will evaluate each "case" and if find a match, it will be executed. In this case the result is "Good morning". Yet if we change the value of the variable $greeting to "afternoon" or "evening" the result will change accordingly.

Friday, May 27, 2016

PHP Delete Data From MySQL

this tutorial help you to delete the inserted data from mysql using php that displayed in webpage, using php functions and mysql queries it's so easy to delete the the data from mysql database table
for this you must have Database in MySql

Read more »

Count Down Script In PHP

This class can show the time left until a moment in different formats. It can take as parameters the specification of a time remaining to a certain moment given the seconds, minutes, hours, days, weeks, months and years. The class can return the remaining time formatted in a a custom way with a given list of time format parameters.

Download Count Down Script In PHP

Mini Blog PHP Script Set Up Your Own Mini Blog

  • Cells Blog is a free but powerful mini-blog system. It can run on any web server that can execute PHP script codes.

  • It comes alone with the SQLite data base so you can copy and play without any installation.

  • Any question please first check to the FAQ in the Cells Blog official web site.

More On Cells Blog...

 Cells Blog is a powerful mini-blog system. It can run on any web server that can execute PHP script codes. It comes alone with the SQLite data base so you can copy and play without any installation. The most important condition is, it is free and you can use it in below conditions.

  •     You can change the logo.gif to your own image on the banner.
  •     You need to keep the Cells-logo and link at the bottom of each page.
  •     The author will continue to improve this system, you can contact and work together with him for improving system. But please dont modify and spread the codes that may disturb the system maintaining.
  •     The author is not to be responsible for any potential problem or damage caused by using this software.

Download Cells Blog- Mini Blog System PHP Script

Illaj e Nabvi aur Jadeed Science Pait Ki Bimariyan


Illaj e Nabvi aur Jadeed Science Pait Ki Bimariyan

Illaj e Nabvi aur Jadeed Science urdu pdf
Free Download Illaj e Nabvi aur Jadeed Science Pait Ki Bimariyan fresh copy of this book is for you.



Open Source Meta Search Engine PHP Script

This is a meta search engine software. It can query several other search engines and collate their results into a final result set. This way you can merge multiple data sources into one search.

Requirements:

  • Web Server: Apache
  • PHP 5.2.0 or later
  • Mod_rewrite
  • GD library

Features:

  • There is a search queries log file.
  • Option to highlight keywords within results.
  • Templates usage. You can control the html code of the page footer, header, results, etc.
  • Depending on the hardware and network it can handle 100,000 - 1,000,000 requests a day.
  • The software has a modular structure.
  • Modules currently included: web(results are returned from Google , Bing , Ask) , images (results are returned from Google , Bing) , news (results are returned from Google , Bing), videos (results are returned from Bing)

Download Open Source Meta Search Engine PHP Script

Thursday, May 26, 2016

Api Google Translate

api-google-translate is a class that can be used to translate text using the Google Translate API. This class is written by Jamie Telin from Sweden.

It sends an HTTP request to Google Translate API Web server passing the text to be translated and the original and target languages pair.

The class decode the JSON response returned by the server and returns the translated text.

Version: 1.1
Required PHP version: 4.1
License: GNU Lesser General Public License (LGPL)

This class can be downloaded either from phpclass/org or here (2kb). The package is including the codes of countries

Auto form PHP Script

This class can be used to generate HTML forms to manipulate MySQL table records. It can take a list of MySQL table fields and generate HTML for forms to select, insert, update, delete table records. The class can also perform given validations of specified fields and invoke given callback functions on certain form processing events.


Download Auto Form PHP Script

Code A Simple PHP Contact Form With A Reply To Option

Today I will show to how to code a Contact form in PHP Which also has a Reply To feature.It is very simple to do so using combination of HTML and PHP.

The Code for the form is given below:

Form Code:
<form action="procesar_form.php" method="post" name="formulario" id="formulario" onsubmit=return validarFormulario()>
<label for="nombre">Nombre </label>
<input type="text" name="nombre" id="nombre" size="60"/>

<label for="apellido">Apellido </label>
<input type="text" name="apellido" id="apellido" size="60"/>

<label for="email">Email </label>
<input type="text" name="email" id="email" size="60"/>

<label for="comentarios">Comentarios</label>
<textarea name="comentarios" id="comentarios" cols="44" rows="10"></textarea>

<input type="button" name="enviar" id="enviar" value="Enviar" onclick="validarFormulario()" /></textarea>

</form>

PHP Code
$email = $_POST[email];


$to = xyz@gmail.com;
$subject = Contacto Us;
$message = Name: . $_POST[name] . " " .
Surname: . $_POST[surname] . " " .
Email: . $_POST[email] . " " .
Comments: . $_POST[comments];
$headers = From: $email . " " .
Reply-to: $email . " " .
X-Mailer: PHP/ . phpversion();


mail($to, $subject, $message, $headers);


header("Location: ../../index.html");

Just put it all together and you are ready to go.I hope you enjoyed this free php script

Enjoy!

MyBB Forum Software In PHP

An Easy to Use forum php script
Both for you and your visitors


A lot of thought has gone into the MyBB interface to make it easy to use. MyBB uses a standard discussion board structure in php, so your visitors will feel familiar with the way MyBB works. Your visitors can use the MyBB user control panel to change the way they view discussions. They can also easily start and reply to discussions and markup their posts. The forum administrators and moderators can use MyBBs inline editing and moderation features to control discussion and keep the forum tidy.

Administration
Complete control over your forum


MyBBs administration panel is extensive and allows you to control every aspect of your discussion board. You can easily change the behavior, layout, options and structure of your discussion board. If you want to prevent users from posting more than once every x seconds, you can do that. If you want to enable your users to add a signature to their posts, you can do that too. Adding custom MyCode can be done just as easily as managing the display of posts and threads.

Plugin System
Easily extend forum functionality


MyBB has one of the most advanced plugin systems found in bulletin boards today. It takes only minutes to install plugins that can make MyBB suit your needs even better. The active and friendly MyBB community    has developed a large amount of plugins that are ready to use; amongst them are plugins to show all unanswered threads, extend the forum statistics, show the permissions one has in a forum and many more.

Download MyBB Forum PHP Script

News Publishing PHP Script

The EasyMyNews is a free, simple, user friendly, php based news publishing script. You can easy publish and administrate your News! There is no need for a database. It is distributed under the GNU General Public License.

Download News Publishing PHP Script

Wednesday, May 25, 2016

Simple Member PHP Script Add Protective Area On Your Website

Simple Member allows you to put up that much needed protective area on your web site where you don’t want anyone snooping without first signing up. This is a real simple membership script written in PHP 5+ that requires MySQL 5+ to run it on your website.

Requirements

    PHP 5+ -http://www.php.net
    MySQL 5+ – http://www.mysql.com
MySQL Database Setup

    Open sql.txt using any text editor. (located in the main Simple Member folder)
    Paste the contents into a tool that can execute SQL commands for your MySQL DB

Installation

    Follow the MySQL Database Setup Before Continuing
    Open main.php with any text editor in the root folder and modify the settings for your server
    Upload to your server

How to Use Simple Member
    At this time there are no admin utilities to view, edit, remove your members, etc.
    The login / add member php script is located at http://domain/to/main/path/index.php
    Your members area would be located in member.php … so this is where you would put content that you want only your members to see. You may copy member.php into a new file to add multiple member restricted pages. Look for the MEMBER CONTENT GOES HERE comment.

Download Simple Member PHP Script

Jinnat Ka Postmortem Urdu PDF

Jinnat Ka Postmortem Urdu PDF

Jinnat Ka Postmortem book free
Jinnat Ka Postmortem Urdu PDF Book is Contains on Nabi Pak Sunnat Aamal  and Al Quran Amal for Jinnat Issues and problems.




PHP File Delete

You know how to create a file. You know how to open a file in an assortment of different ways. You even know how to read and write data from a file!

Now its time to learn how to destroy (delete) files. In PHP you delete files by calling the unlink function.

Chalta Phirta Encyclopedia By Maqsood Ahmed Chughtai


Chalta Phirta Encyclopedia By Maqsood Ahmed Chughtai

Chalta Phirta Encyclopedia free download book
Chalta Phirta Encyclopedia 


  Free  Acquire   or even  read  on the net  Urdu book Chalta Phirta Encyclopedia  written by  Maqsood Ahmed Chughtai.  individual   which  A Brief knowledge  exactly about  immigration law  regarding   some other  country  world knowledge  that  Country  would be the   Best  hot spot  regarding  instructors  AS WELL AS  understudies  for you to   identify  general  information about  diverse  international locations   About the  world.




Simple Image Gallery Image Gallery Management System In PHP

Simple Gallery is an easy to use image gallery management system written in PHP and utilizes jQuery, MySQL, and the GD Library. It allows multiple categories and subcategories as well as image hit / download tracking and a built in installer. Also, the latest version adds support for Thickbox displaying of images when downloading.

Requirements
  •     PHP 5+ -http://www.php.net
  •     GD Library – http://www.libgd.org
  •     MySQL – http://www.mysql.com

Installation
  •     Open “inc/config.php” and modify the settings to your liking
  •     Do Not Run the “install.php” script before doing the above
  •     To use an existing mysql database, just set “$db” in “inc/config.php” to the DB name you wish to use
  •     If the DB name you specify in “$db”, the install.php script will attempt to create it for you.
  •     3 database tables will be added to your DB name above “freephp_gallery, freephp_gallery_admin, freephp_gallery_category”
  •     The directory you specify for “$base_dir” should be chmod to 777 (full permissions)
  •     When you are sure your settings are correct, run the “install.php” file
  •     You will be asked to create your admin username and password on the install.php page
  •     After completing the install, REMOVE “install.php” (running this again will remove any data from your Simple Gallery tables)
  •     Run “login.php” to login as the admin username and password you setup so that you may start using Simple Gallery

Download Simple Image Gallery PHP Script

Tuesday, May 24, 2016

Securing Logo Image

Sometime, you may want to secure a logo (image) on your user-interface to avoid some replacement.
In that case we can encode the image to a text-base code. To do that we need img2php class which can be downloaded from phpclasses.org or you can download it here (12.7kb including samples) 

Following are the example of steps after extracting the package:
1. write this script
<?php
require_once("img2php.class.php");
$t = new img2php;
$t->generate("images/"); //place image(s) in a subfolder
?>

2. run the script and the result should be similiar to this:
<?php
        
/**
 * gonximage class : Generated based on directory (images/)
 * 
 * @package 
 * @author Ben Yacoub Hatem <hatem@php.net>
 * @copyright Copyright (c) 2004
 * @version $Id$ - 2009-03-11 11:03:42 - gonximage.class.php
 * @access public
 **/
class gonximage{
    /**
     * Constructor
     * @access protected
     */
    function gonximage(){
        
    }
    
    /**
     * Return image based on it name
     * @access public
     * @return void 
     **/
    function getimage($img){
        switch($img){

            case "orchid_jpg": 
                gonximage::orchid_jpg();
            break;

        } // switch
    }
    function orchid_jpg() 
    {
        header("Content-type: image/jpg");
        header("Content-length: 3980");
        echo base64_decode(
/9j/4AAQSkZJRgABAgAAAQABAAD/4QDmRXhpZgAASUkqAAgAAAAFABIBAwAB.
AAAAAQAAADEBAgAcAAAASgAAADIBAgAUAAAAZgAAABMCAwABAAAAAQAAAGmH.
BAABAAAAegAAAAAAAABBQ0QgU3lzdGVtcyBEaWdpdGFsIEltYWdpbmcAMjAw.
OTowMToxMiAyMjoyOTo0MwAFAACQBwAEAAAAMDIyMJCSAgAEAAAANDE4AAKg.
BAABAAAAjAAAAAOgBAABAAAAtAAAAAWgBAABAAAAvAAAAAAAAAACAAEAAgAE.
AAAAUjk4AAIABwAEAAAAMDEwMAAAAAAAAAAA/8AAEQgAtACMAwEhAAIRAQMR.
Af/bAIQAEw0OEQ4MExEPERUUExcdMB8dGhodOyotIzBGPkpJRT5EQ05XcF9O.
UmpUQ0RhhGJqc3d9fn1LXYmTiHmScHt9eAEfISEsJixWLy9Wtnlneba2tra2.
tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2tra2.
/8QAfQAAAwEBAQEAAAAAAAAAAAAAAgMEAQUABhAAAgEDAwMDAwIFAgcAAAAA.
AQIRAAMhBBIxIkFRE2FxBTKBUpEUI0KhwWLwJDNT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4qqKqtdF3wiExVN656FlNwXeE7D+1BSX7.
j7/SJxgmexivWrxtXGK5BEc4qQLbuL28RMznihu2SssIAOY8VAmK8BUm96YA.
IpIOK0ChOvZtyioZJCzAHFUekFX7o+eaIU1zYDltznuDgVFeGcCY5pgpXYCi.
FxhZNqRsZtxxk+KQ2yAjBzkLmnrF9LW5TL3SOcAYmgkXnS4zsBBZifx2pPya.
k2TtPtS97EQWJFIZXu1CaOaaaiXRJlh81J1NGGF9yC2QRg5NPF1P6gXnHMCg.
prlxVB2ruY9+AtSXAWPME5OaQHvt4oWEZPekPAYnFX2Rt06uYiyrEgfqbAFC.
c6OkV7kQKk8eDQqmc1J51igqQ0HWKZUSxWrUlqsRicHBqstssEqqz8UETWw9.
gseR4qJ7am0W7gUolz1/igbO4eKgJAN0e1Ux/wALYXtcutu94gCkJHADECh7.
VJ5hFBuM80J5uaGpDT7hRVF//9k=.
);
    }


}
?> 

3. copy and save the result above (for instance encode.class.php)
4. write a script to show the image (show.php):
<?php
include "encode.class.php";
$img = new gonximage();
$imgfile = "orchid_jpg";
$img->getimage($imgfile);
 ?>



A simple Validation Form in PHP

Today I am going to share a simple script in PHP which does the validation when user registers with your site.It is a very simple one and aimed at a complete newb.I am not going to discuss much about the script as it is pretty much self explanatory.The script is given below:

<?php 
}
else {
$usr = new Users;
$usr->storeFormValues( $_POST );
$n6 = 6;

if( $_POST[password] == $_POST[cpassword] ) {
echo $usr->register($_POST);
}
else {
echo "Password and Confirm password not match";
}

if( $_POST[username] < $n6 ) {
echo "Username must be more than 6 characters.";
}
else {
echo $usr->register($_POST);
}

if( $_POST[password] < $n6 ) {
echo "Password must be more than 6 characters.";
}
else {
echo $usr->register($_POST);
}
}
?>
Thats it with it.You may change it according to your needs.Besides, if your are working on a Registration form then you will also find the Login Form in PHP interesting.

Enjoy!

PHP Script To Parse Out Common Phrases In A Document

Today I will discuss with you a function written in PHP which will enable you parse out common phrases in a document.
function getPhraseCount($string, $numWords=1, $limit=0) {
// make case-insensitive
$string = strtolower($string);
// get all words. Assume any 1 or more letter, number or in a row is a word
preg_match_all(~[a-z0-9]+~,$string,$words);
$words = $words[0];
// foreach word...
foreach($words as $k => $v) {
// remove single quotes that are by themselves or wrapped around the word
$words[$k] = trim($words[$k],"");
} // end foreach $words
// remove any empty elements produced from trimming
$words = array_filter($words);
// reset array keys
$words = array_values($words);
// foreach word...
foreach ($words as $k => $word) {
// if there are enough words after the current word to make a $numWords length phrase...
if (isset($words[$k+$numWords])) {
// add the phrase to list of phrases
$phrases[] = implode( ,array_slice($words,$k,$numWords));
} // end if isset
} // end foreach $words
// create an array of phrases => count
$x = array_count_values($phrases);
// reverse sort it (preserving keys, since the keys are the phrases
arsort($x);
// if limit is specified, return only $limit phrases. otherwise, return all of them
return ($limit > 0) ? array_slice($x,0,$limit) : $x;
} // end getPhraseCount

//examples:

getPhraseCount($string); // return full list of single keyword count
getPhraseCount($string,2); // return full list of 2 word phrase count
getPhraseCount($string,2,10); // return top 10 list of 2 word phrase count

Description:
Okay, so basically this function will take the string and return a phrase => count  associative array.  If you only pass it the string, it defaults to doing a count of individual words and returning all of them in descending order.  Optional 2nd argument lets you specify how many words in the phrase.  So if you put 2 as 2nd argument, it will go through and for each word, take the word and the word after it and count how many times that 2 word phrase occurs, returning the list in descending order.  If the optional 3rd argument is used, it returns top x amount of words, so like 10 would return top 10 phrase occurance.

Limitations:

  • hyphenated words are not matched.
  • case in-sensitive.
  • assumes $string is "human" readable text.  In other words, if you were to pass a file_get_contents of some webpage to it, you should probably strip_tags() first, as well as do some regex to remove stuff between php script tags, etc...
If you enjoy reading this post then consider Subscribing to our blog in order to keep yourself updated with similar useful posts.