August 10th, 2010
With the help of smartwebby.com, we are able to show you the basic example when sending an email in PHP.
Syntax: mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
Ex:

Sample PHP Code:
<?php
//Check whether the submission is made
if(isset($hidSubmit)){
//Declarate the necessary variables
$mail_to=$txtEmailto;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,”From:$mail_from/r/nReply-to:$mail_from”))
echo “<span class=’red’>E-mail has been sent successfully from $mail_sub to $mail_to</span>”;
else
echo “<span class=’red’>Failed to send the E-mail from $mail_sub to $mail_to</span>”;
}
?>
Posted in
PHP |
No Comments »
July 10th, 2010
During the 80’s, people still communicate through snail mails until electronic mails came in. Most professionals in today’s time spend 50% of their working time using e-mail and its use is no doubt increasing due to globalization.
Sending emails procedure varies. One of them is sending in PHP. Mails in PHP are easily sent with the help of library function ‘mail‘.
This function takes four parameters to send E-mails from a PHP page and returns ‘true‘ upon successful delivery of Email. The parameters of this function are as follows:
- Recipient
- Subject
- Message
- Headers (Sender E-mail address)
Posted in
PHP |
No Comments »
June 10th, 2010

Date Validation in PHP
This tutorial will show how to Validate Date fields using PHP code in ‘dd/mm/yyyy’ Format. It is a good practice to validate the date value when it is obtained using forms through user input.
PHP CODE:
//Check whether the submission is made
if(!isset($_POST["hidSubmit"])){
//Declarate the necessary variables
$strdate="";
$strdate1="";
DisplayForm();
}
else{
$strdate=$_POST["txtdate"];
//Check the length of the entered Date value
if((strlen($strdate)<10)OR(strlen($strdate)>10)){
echo(“Enter the date in ‘dd/mm/yyyy’ format”);
}
else{
//The entered value is checked for proper Date format
if((substr_count($strdate,”/”))<>2){
echo(“Enter the date in ‘dd/mm/yyyy’ format”);
}
else{
$pos=strpos($strdate,”/”);
$date=substr($strdate,0,($pos));
$result=ereg(“^[0-9]+$”,$date,$trashed);
if(!($result)){echo “Enter a Valid Date”;}
else{
if(($date<=0)OR($date>31)){echo “Enter a Valid Date”;}
}
$month=substr($strdate,($pos+1),($pos));
if(($month<=0)OR($month>12)){echo “Enter a Valid Month”;}
else{
$result=ereg(“^[0-9]+$”,$month,$trashed);
if(!($result)){echo “Enter a Valid Month”;}
}
$year=substr($strdate,($pos+4),strlen($strdate));
$result=ereg(“^[0-9]+$”,$year,$trashed);
if(!($result)){echo “Enter a Valid year”;}
else{
if(($year<1900)OR($year>2200)){echo “Enter a year between 1900-2200″;}
}
}
}
DisplayForm();
}
//User-defined Function to display the form in case of Error
function DisplayForm(){
global $strdate;
Explanation
*Expression ^[0-9]+$
^ :-Indicates the beginning of the string
[0-9]+ :- indicates that the string begins with a number between (0-9) and is followed by numbers.
$ :- Indicates the end of the String
Posted in
Information |
No Comments »
May 10th, 2010
A PHP scripting block usually starts with . The best thing about PHP scripting block is that you can place it anywhere in the document. placed anywhere in the document.
On servers with shorthand support enabled you can start a scripting block with .
It is recommend that you use the standard form
< html >
< body >
< ? php
echo "Hello World";
? >
< /body >
< /html >< /em >
Every line in PHP ends with a semi-colon. The two basic output text in PHP are: Echo and Print.
Posted in
Information |
No Comments »
April 10th, 2010
Libraries > PHP includes a large number of free and open source libraries with the core build.
Extensions > PHP allows developers to write extensions in C to add functionality to the PHP language. These can then be compiled into PHP or loaded dynamically at runtime. Extensions have been written to add support for the Windows API, process management on Unix-like operating systems, multibyte strings (Unicode), cURL, and several popular compression formats. Some more unusual features include integration with Internet relay chat, dynamic generation of images and Adobe Flash content, and even speech synthesis. The PHP Extension Community Library (PECL) project is a repository for extensions to the PHP language. -Source
Posted in
PHP |
No Comments »
March 10th, 2010
What is a Cookie?Cookies are small bits of information that can be stored on a client computer. Once a cookie is created, it will expire after a specified time period. All the information stored in a cookie exist until it expires or deleted by the user.
Why do we need Cookies? Now-a-days most of the websites use cookies to store small amounts of information. Websites can read the values from the cookies and use the information as desired. The browser is capable of keeping track of the websites and their corresponding cookies and is capable of reading the information from relevant cookies. Some common use of cookies include:
- User’s aesthetic preference for a specific site.
- User keys to link them with their personal data – as used by many Shopping Cart Applications.
- Allowing a user to remain ‘logged on’ until he explicitly logs out or the browser window is closed.
-Source
Posted in
PHP |
No Comments »
February 10th, 2010
A function is a block of code that can be executed whenever we need it.
Creating PHP functions:
* All functions start with the word “function()”
* Name the function – It should be possible to understand what the function does by its name. The name can start with a letter or underscore (not a number)
* Add a “{” – The function code starts after the opening curly brace
* Insert the function code
* Add a “}” – The function is finished by a closing curly brace
Example
A simple function that writes my name when it is called:
<html>
<body>
<?php
function writeMyName()
{
echo “Michelle”;
}
writeMyName();
?>
</body>
</html>
Use a PHP Function
Now we will use the function in a PHP script:
<html>
<body>
<?php
function writeMyName()
{
echo “Michelle”;
}
echo “Hello world!<br />”;
echo “My name is “;
writeMyName();
echo “.<br />That’s right, “;
writeMyName();
echo ” is my name.”;
?>
</body>
</html>
The output of the code above will be:
Hello world!
My name is Michelle.
That’s right, Michelle is my name.
Posted in
PHP |
No Comments »
January 10th, 2010
PHP stands for PHP: Hypertext Preprocessor. It is a server-side scripting language wherein the scripts are executed on the server itself. PHP is an open source software and is free to download and use. MySQL is a database server that is ideal for both small and large applications. MySQL can compile on a number of platforms and just like PHP, it is free to download and use. Both are open to everybody who wants to learn more on this.
PHP combined with MySQL can create a cross-platform which means that you can freely develop in Windows and serve on a Unix platform.
Posted in
PHP |
No Comments »
December 9th, 2009

The golden rule on the world wide web is that one should “never-ever-ever trust user input”. Given this, it would be wise to spend quite some time to make sure that all of the inputs from the users in able to make sure it is safe and what was expected..
There are several things to should watch out for when validating input:
Mistaken input.
For example the user types 99.7 rather than 9.97
Bad input
The user provides incorrect input in on purpose for whatever reason.
Dangerous input
User innocently enters information that would harm the system
Missing input
User provides no input.
Posted in
PHP |
No Comments »
November 10th, 2009

PHP can be done through a lot of programming languages. This can be from the simple notepad authoring (a practice that can be done by advanced programmers who are already familiar with PHP programming) or from PHP ready programs such as Dreamweaver.
It would be best however to read on more on which software can be suitable for you. PHP is a common scripting technique these days and some even download basic scripts and enhance them afterwards. This approach is actually a learning process and in the end, you will find yourself starting from scratch and making your own scripts for self-improvement in the world of website design and development.
Posted in
Basic Programming |
No Comments »