First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Exercise's and Fun configuring PHP

Exercise:  Sending Email with PHP from your local computer.  
This will work depending on if your ISP does not specifically restrict it.  Open up the PHP.ini (c:\windows\PHP.ini) file and find the following lines that look like this:

; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from =
me@localhost.com

Change this to:

; For Win32 only.
SMTP = mail.yourISP.com

; For Win32 only.
sendmail_from = YourName@YourSite.com

The SMTP setting 'mail.yourISP.com' should be the same outgoing SMTP setting you have specified in Outlook.  As long as you can send and recieve email from Outlook and have the username and password set in Outlook, you'll be able to do the same with PHP.  (Remember to Restart Apache after you have made the change to the PHP.ini file!). 

You test this by creating a file called:  EmailTest.php and placing this in your htdocs folder.  Add the following to this file:

$FromName = "Jeff Hill";
$FromEmail = "Jeff@Flash-db.com";
$ToName = "Someone";
$ToEmail = "SomeTest@someemail.com";
$ToSubject = "Testing Email from my Computer";
$Message="This is a test - hopefully I get this email";

mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FromName." <".$FromEmail.">");
print "Success, the Email has been sent to $ToEmail, they should be receiving it shortly.";
?>

Then run this by opening up a browser window to the URL:  http://localhost/EmailTest.php.  If you want to create a flash movie that allows you to send email.  Remove the first 6 lines from this script - then create a flash movie with corresponding Input text boxes with the same variable names - such as FromName, ToEmail, Message etc.  Then make a button with the following actionscript on it:  loadvariablesNum("EmailTest.php", 0, "POST");  this will send the variables a user enters to the modified script and send the email.  (This is a very very basic method - but hopefully you get the idea).  Make sure that the swf is in the same directory as EmailTest.php.  Also note that you can not use the "POST" method from within the Flash editing tool ie "Test Movie" (you can use GET however) - so you'll have to run this in a SWF in a browser, ie http://localhost/Email.swf.  For more information on creating an Flash Email client - check here.


Exercise:  Enabling Additional PHP Extensions
Along with everything else that PHP can do - their are tons of additional extensions you can load that cover just about everything and anything you can think of:  From writing and manipulating Flash, PDF, Image files from code to special xml functions to secure shopping cart extensions.  Most of the time it's hard to convince your systems admin to enable some of these extensions for you if your in a shared hosting environment - but in this case since we are the systems Admin we can do whatever we want.  

Open up the PHP.ini file again (see how much the shortcut on your desktop helps).  Then find an area marked by ;Windows Extensions followed immediately by a long list of items that look like:  ;extension=******.dll.  For this example where going to install the Ming Extension and the GD Extension.  

Remove the semi-colon ;  from the beginning of these two extensions (ie ;extension=php_ming.dll to extension=php_ming.dll).  Save the PHP.ini file and restart Apache.  Now your able to use all of the Ming Functions as well as all of the GD functions.  (Ming is a set of tools that allow you to create SWF movies on the fly with Code) (the GD library is a set of functions that allows you to create and manipulate images with code).  


Exercise:  Parsing .html (and other file types) as PHP - with Apache and .htaccess files.
(This is optional like all the other exercise's).  You can add a couple lines to either the main Apache httpd.conf file or to .htaccess files in specific directories to parse certain file types as PHP.  This is useful if you don't want to others to know what type of scripting language your using.  With the following line of code you can parse .html files for PHP code - meaning that files ending with .html can be used in the same way as files ending with .php.

Add this line of code to either the Apache httpd.conf file or to a .htaccess file in a specific directory:
AddType application/x-httpd-php .html

Where not limited to being able to do this with just .html type files.  You can do this with basically any type of file.  For example if we wanted someone to think that we where using ASP instead of PHP we could add this line:
AddType application/x-httpd-php .asp 
This would allow you to parse all .asp type file's as PHP (obviosly they have to contain PHP code however and not ASP code).

Try to have fun with it!  I like to make up my own File Extensions such as .Jeff
AddType application/x-httpd-php .Jeff
Now I I can create files like Testing.Jeff  - Put some PHP code in their and open up http://localhost/Testing.Jeff  And that file will be parsed as PHP.  With your own file extensions parsed as PHP on your site - anyone taking a look at your site will be like what the heck is going on here..  (If you really don't want people to know what your using change this line in the PHP.ini file expose_php = On to expose_php = Off).  Some really large sites will do this to avoid giving a potential hacker even the slightest clue as to what Scripting language their using.

Next we'll Take on installing MySQL

» Level Advanced

Added: 2002-05-08
Rating: 9 Votes: 108
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.