TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-20-2010, 09:06 PM   #1 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default Attaching image file to email form

I am trying to allow users of my website to be able to send and attach files when they use my contact form. I have never actually messed around with this type of thing. But this is going to be kind of essential and help increase my business (hopefully) here is what I have right now this works I just want to add the attach file to it but not sure where to start. Help please?

PHP Code:
<?php

$sendTo 
"Email Here";
$subject $_GET['csubject'];
$message $_GET['cmessage'];
$email $_GET['cemail'];
$name $_GET['cname'];
$phone=$_GET['cphone'];
    

//send mail info
    
$headers  "From: $email\r\n";
    
//$headers .= 'MIME-Version: 1.0' . "\r\n";
    //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        
$msg "\n\n Name:".$name."\n\n Phone:".$phone."\n\n E-Mail:".$email."\n\n Message:".$message."";

//send mail    
    
mail($sendTo$subject$msg$headers);
?>
KingOfTheSouth is offline  
Reply With Quote
Old 05-21-2010, 01:29 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

My first suggestion would be to avoid recreating the wheel. There are libraries out there that make this stupid simple, such as PHPMailer.

That aside, if it's for learning purposes, if you have plans to make this available for your web site, I would work heavily on doing some form validation. You're using unvalidated unfiltered values which opens you WIDE up to a variety of attacks. Don't forgo security in favor of speed to complete an application, ever.

You are going to want to look up php file handling, in particular, the $_FILES superglobal that automatically populates with information from a forms file input field. The next thing you are going to want to research is the proper mail headers to attach a file, as the basic headers you are sending above won't permit this.
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Reflections in PHP Rendair Advanced PHP Programming 17 11-30-2011 08:41 AM
php/html form to echo text file contents Hustle Absolute Beginners 2 03-10-2009 07:14 AM
email fill in form help? PHP sacred_tinker Absolute Beginners 19 05-28-2008 05:58 AM
Email form - validates email by checking a/mx records of domain. Sam Granger Script Giveaway 4 03-30-2008 05:58 PM
A form of a image class.. Tanax Advanced PHP Programming 10 01-23-2008 07:21 PM


All times are GMT. The time now is 01:48 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design