PHP Form to Email Script

Posted by Mike Lopez under Technology
1 Comment
Mar 2006
22
11:06am


So you want to send emails via an online (HTML) contact form?  It’s pretty simple.
In our example, we will be using two files - one to gather the input through an HTML form and another to send the email.  We will call these two files form.php and process.php respectively.
form.php - is the HTML form where a user can input his name, email, subject, and message
process.php - is the PHP script that will send the email to you.  So let’s proceed.
First we create your form - form.php:


You may insert the above code in any HTML page that you want but for our example we will call our html page “form.php”
Next, we create the email sending script which we will call “process.php” and put the following code in it:


Now, upload these two files on your server and give it a try.  Enjoy.  If you have questions, feel free to post them below.



PHP Image Resize Script

Posted by Mike Lopez under Technology
165 Comments
Mar 2006
02
12:59pm

So, you want to resize an image in PHP? PHP Image resizing has not been so easy especially to newbies so let’s make this as simple as possible. All you have to do is save the script below to a file named ‘imgsize.php’ and give it a try. I use it myself on some of my projects and I wrote the script myself. Some usage examples are listed below after the script.

Click here to VIEW SOURCE CODE. Save file as imgsize.php.

Usage examples:

Resize an image to 25 x 25
imgsize.php?w=25&h=25&img=path/to/image.jpg

Resize an image to 50% the size
imgsize.php?percent=50&img=path/to/image.jpg

Resize an image to 50 pixels wide and autocompute the height
imgsize.php?w=50&img=path/to/image.jpg

Resize an image to 100 pixels tall and autocompute the width
imgsize.php?h=100&img=path/to/image.jpg

Resize to 50 pixels width OR 100 pixels tall, whichever resulting image is smaller
imgsize.php?w=50&h=100&constrain=1&img=path/to/image.jpg

Now enjoy yourself!

Questions, comments, suggestions? Post them below.

P.S. Here’s a user (Brian Marshall) contributed set of instructions on how to use the script. - Read it.


Uploading Files in PHP

Posted by Mike Lopez under Technology
1 Comment
Mar 2006
02
05:42am

So you want to upload files using PHP?  If so, then here’s a sample script on how to do it.  Just copy it and paste it to a file named file_upload.php then change $upload_dir to your upload directory.  Note that your upload directory should be writable otherwise, the file upload will fail.

Also, for simplicity, this script uses a single-file approach wherein the html form is placed in the same file where the PHP upload processing is made.  You can separate these two sections into two different files if you wish - one for processing the upload in PHP and another for the HTML form but then you will have to make some changes to the script - I will leave that for you to find out.

Filename : file_upload.php*** Start Copying ***



*** End Copying ***

Post your questions, comments, suggestions, and other messages below.