PHP Code Snippet Index

PHP Proxy Solution for cross-domain AJAX scripting

This is a PHP script that allows javascript clients to request content they otherwise would not be able to. With the popularity of AJAX (using the XmlHttpRequest object in the browser), many developers are becoming aware of the cross-domain scripting limitation. This is a security feature that... (Read More)
-1

Private Messaging system

This one is a messaging system! Made it myself, works great! Hopes you like :) (Read More)

Javascript not working in PHP class file

I am in the process of learning PHP with JS and Ajax and have the foll. problems. I have created a class to generate master data entry screens. (1) Javascript code that works when I run master.class.php independently does not work when I run users.php. I came across this problem while trying to... (Read More)

Export CSV TO Mysql and Import to CSV from MYsql in PHP

Export CSV TO Mysql and Import to CSV from MYsql in PHP (Read More)

Save, edit & update languages in one time

I wont describe whats here, just figure it out yerself, enjoy =) (Read More)

Ping

Ping a server (Read More)

parse error on last line (line 802)

this php n html code is supposeed to allow editting of property info/details (Read More)

PHP Login Script

Here is a simple login script (Read More)

generate a PDF and send as attachment

FPDF is a class that provides a useful way to deal with PDF documents using dynamic content. Sometimes, according to a special circumstance, also would be valuable to send directly the PDF as attachment e.g. send an invoice automatically after processing a payment. In this example we use a html... (Read More)
1

Filter url to domain

In these three functions, you can filter to a url to just the domain name. There are three main methods of doing so which are all shown in the example and the usage of each function is shown in the example. (Read More)

Storing Passwords Securely in Database and Cookies

I am posting this code snippet as I continue to see login and user registration scripts that store passwords in databases as unsalted md5 hashes, and passwords in cookies as raw text. This snippet includes an example user registration function, as well as an example user login, login check, and... (Read More)

Greeting the Guests & Users

This tutorial shows how to greet your visitors depending on what time of day it is. If it's morning, it greets your visitor with "Good Morning!" If it's afternoon, it greets them with "Good Afternoon!" Magic? Noooo! Just PHP! We will start by looking at the entire script and then dissecting it... (Read More)

Delete Records With Effect Using jQuery And PHP

Overview this is a fast way to delete Records from your mysql datebase without loading the page . this jquery code can Delete a Record with animation fade-out effect using jQuery and Ajax. <FAKE SIGNATURE> (Read More)

Fill Function

Got bored and made a function that handles filling strings similar to mysqli bind_param. It actually gets used a lot in my code. Figured someone else might find it useful. Example usage: Using question marks as place holders $str = 'Hello, my daniweb user name is ? and my real name is ?';... (Read More)

Find String in PHP Ready easy function

Better way to find String in PHP ! instead of substring and other php function , This function takes Start and End , and it will return the String in between in another variable ! you can call it easily :) (Read More)

CURL PHP Ready function !

This is CURL Ready function , to use it just call do post if the page you are calling has post variables , or get if it has get variables :) (Read More)

PHP HTTP Screen-Scraping Class with Caching

class_http.php is a "screen-scraping" utility that makes it easy to scrape content and cache scraped content for any number of seconds desired before hitting the live source again. Caching makes you a good neighbor! The class has 2 static methods that make it easy to extract individual tables of... (Read More)

This is it!!

This is it, I've completed my forum script and I'm sharing it with you!!!!!!! :O Hope you like it, if you find any bugs, please post it here Oh yea, and the first registered person will be the admin (Read More)
1

PHP Register Script

A simple register script (Read More)

Currency Converter

Hi there peoples, This is a currency converter, built with a combination of javascript and php, which uses an XML feed from http://www.ecb.int/ to get up to date exchange rates. I know the xml handling is not very elegant, but it is functional :) Additions/comments/corrections welcome (Read More)

Browser Forced Download of Adobe Acrobat .PDF Files.

Do you work with datasheets regularly ? Always getting .pdf files open in your browser and having to wait EONs for them to download/display ? Well here is a resolve for that most frustrating of problems with Adobe's "Handy file intercept" feature. Use this script to FORCE the browser to download... (Read More)

A simple OLE automation using COM

well PHP is a powerfull text processing language designed mainly as a CGI ( common Gateway Interface ) programming language. But PHP supports rest of other features using the library extensions. For a example you can call any win32 API call in your PHP script using the win32 API library... (Read More)

Extremely Simple Menu Generator

This is about as simple as it gets with menu generators. Everything is explained in the code. Note that the menu is simply an unordered list so to pretty it up it really relies on the CSS. If you don't want to write any CSS of your own here is a sample stylesheet. #Menu {... (Read More)

Resizing an image

this script, made by me, lets you resize an image propotionally! (Read More)

XML-style BBCode parser

I answered a question a few days ago on Yahoo! Answers where I helped (did all the work for) the question asker. They were asking for a way to parse text from a <textarea> and search for HTML-like elements that were named in a database (or an array, in my case). Took a few hours to write a... (Read More)

PHP Email Address validation through SMTP

Here is a PHP class written for PHP4 and PHP5 that will validate email addresses by querying the SMTP (Simple Mail Transfer Protocol) server. This is meant to complement validation of the syntax of the email address, which should be used before validating the email via SMTP, which is more resource... (Read More)

Simple PHP Pagination - No Database Required

The following snippet is a simple PHP Pagination Script which I wrote. As far as I know it works fine. It is meant to be used within a class, and I have wrapped in in a class in order to demonstrate it's usage. The example given below will return something similar to the following: Pages: >... (Read More)

PHP Class for Google AJAX Language API (Language Translation)

This class allows you to use the Google AJAX Translation API to translate arbitrary text to the many languages supported by the Google API. Source versioning added to: http://code.google.com/p/php-language-api/ (Read More)

General Date Convertor and Calculator (Simple)

A simple function to change between common formats, e.g. UK, US, Unix dates and datetimes. Also allows the addition/subtraction of months, years, seconds etc etc. I have only set up a few formats in the function, but it can beeasily developed. (Read More)

GETTING PAID by time locking templates

I absolutely hate it when I trust a person and never collect a deposit on work only to NOT be paid when I'm done. I recently designed a flash page turn effect that is all XML controlled for a Realtor where the agents could simply upload the images to a folder, use the online editor to edit the... (Read More)

PHP WebDAV for Microsoft Exchange Server

Does your organization use Microsoft Exchange? Do you have a need to incorporate your Exchange data with your PHP web applications? You can use the WebDAV methods to query your Microsoft Exchange Server using the PHP scripting language. Once you wrap your brain around these techniques,... (Read More)

Long Date Language Translator

A simple example of date (day and month) translation. The code is for Welsh, but can be easily modified for any language - especially those without "full" support. I have used the code in a footer to display the last updated date and time. (Read More)

(Back) link checker

This function is usefull for peoples with a link directory where the links are stored inside a (MySQL) database. The PHP script is easy to use to find out if a reciprocal link still exists on the corresponding webpage. It takes care about the trailing slash in urls and can be used with (almost)... (Read More)

Functions to validate e-mail, name and phone number

Here are two simple functions to validate name and e-mail . int valName( string $arg1 ) - this function returns 1 if name is correct, 0 if incorrect int valMail( string $arg1 ) - this function returns 1 if name is correct, 0 if incorrect (Read More)

Backtracing Function Calls

So you've got this big long function chain and PHP's oh-so-helpful Fatal Error messages aren't helping at all. Here's a quick example of how to do a function backtrace without throwing exceptions. Output: => => Array ( => someFile.php => 4 ) => Hello World (Read More)

Distributing an HTML email to a mailing list

This function distributes mail to a mailing list, out of an array. Wether the array is plundered from a database, a file, or from the code, the function only takes a prepared one. Also, this function is only good for HTML messages. The array's syntax is to be: array("recipent's... (Read More)

Emulating Register Globals

Ever since PHP turned register_globals_off I have had problems here and there in my codes. I searched hard and long for a simple fix while keeping globals turned off. Fortunately, I found one! I have posted it below for your convenience and it is also described Here. I'm not sure if this has... (Read More)

delete all files in folder on server

this code will delete all the files from a directory on the server. be careful when using this as it will delete everything in the directory so use it wisely or make sure you have backups if it is implemented on the wrong directory. it works by searching for all the file which have a full stop... (Read More)

CSS Bar Graph function

This is a recursive function I made to draw purely CSS bar graphs. You pass it an array of data and the total amount, example: $someData = array('Oranges'=>4, 'Apples'=>10); $total = 14; echo drawCSSGraph($someData, $total); Also, you can pass it options in the form of an array or as space... (Read More)

Display images from server in email

This code will display images within an email from the server. It will display an image with a choice of file extension which can be expanded to fit your needs. this code was originally developed for a emailing system where the images to be displayed where uploaded by the user. (Read More)

Forum Tools


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC