Archive for February, 2008

PHP Image Uploader Program Code

Friday, February 29th, 2008

This PHP Program is useful when you want to upload images only.

$numoffiles = 5;
echo '

‘ ;
for ($i = 1; $i<=$numoffiles; $i++)
{
echo 'Image'.$i.':
‘;
}
echo ‘
‘;
echo ‘

‘;

if(isset($_POST['action']))
{
$uploaddir = ‘C:/PHP/uploadtemp/’;
for ($i =0; $i<$numoffiles; $i++)
{
$filename = $_FILES['file']['name'][$i];
$filetmp = $_FILES['file']['tmp_name'][$i];
$filesize = $_FILES['file']['size'][$i];
$filetype = $_FILES['file']['type'][$i];
$ext = substr(strrchr($filename, "."),1);
$conf = $uploaddir . $filename;
$filepath = $uploaddir . $filename;

if ($filename != "")
{

if (!file_exists($filepath))
{
if ($ext == "jpg" || $ext == "gif" || $ext == "tiff" || $ext == "png" || $ext == "bmp")
{
if($filesize < "500000")
{
$upload = move_uploaded_file($filetmp, $filepath);
echo '‘. $filename . ‘ was successfully uploaded…
‘;
}
else
{
echo ‘‘.$filename . ‘ greater than the maximum file size allowed…
‘;
}
}
else
{
echo ‘‘. $filename . ‘ is invalid file type…
‘;
}
}
else
{
echo $filename . ‘ already exists…
‘;
}
}

}
}

?>

Single Quotes and Double Quotes Rage On

Thursday, February 28th, 2008

Don’t you know whenever you place ‘double quotes you are asking for PHP to look after the content of a variable? PHP will still waste valuable computing time scanning lines even if the following lines do not contain variables inside the double quotes.

Such three lines of codes can be done even speedy if “single” quotes were used in place of “double” ones.

In the present, that may not seem like much, but making PHP check for variables where it doesn’t need to over the course of a larger script, can certainly impede run-time. Just to clarify my point, PHP will not read a variable if it is within ’single’ quotes.

To keep your scripts fast in your server, avoid double quotes at all costs. Even if you’re working with variables yet you’re thinking of using double scripts.

The Most Recommended Web Programming Today

Wednesday, February 27th, 2008

One of the simplest tools for web applications is the ASP.Net with C# or VB.Net. The C# is the future language for the web which speeds up the development cycle, and other suggested languages for the web. Also, JavaScript syntax would not be too difficult to pickup C#. Likewise, if it is with VBScript, then VB.Net. won’t be difficult to learn.  However, it is a known fact that higher demand goes to the C# developers than those in the VB.NET. The longetivity, validation of technology, the development cycle time and the compatibility concerns should be considered in choosing a platform.

Learning HTML the Easy Way

Tuesday, February 26th, 2008

Learning HTML or Hypertext Markup Language does not require any professional IT experience. This computer application is as simple and easy as it may seem to be. Performing Hypertext in the Word document is as simple as linking a keyword to direct a reader into a specific link. These said links can either be found on the same or other pages with the link that carry on a much broader explanation and variety of other web links of the same topic. This basic HTML Tutorial would best describe common HTML tags needed in learning the fundamentals as well as advance HTML.

Sending Emails in PHP Example

Monday, February 25th, 2008

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>”;
}
?>

Sending Emails in PHP

Monday, February 25th, 2008

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)

Bit Toggle Programming Code Tips

Monday, February 25th, 2008

Toggling a number between 0 and 1 can be a useful tool for any programmers in running a loop and do an irregular action. This alternating format best applies to a two-player game where the first one player goes first upon going through the loop with same rules apply to the second player and the process goes on. However, if you are programming and customizing a high speed game then there should be a one line of code. For example when it is subtracted from one you will get zero and if the answer is one it means it is subtracted from one.


Bad Behavior has blocked 238 access attempts in the last 7 days.