Home | Community | Message Board


Ralphster's Spores
Please support our sponsors.

General Interest >> Science, Technology & Computers

Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Jump to first unread post. Pages: 1
InvisibleTrav
Stranger

Registered: 06/09/05
Posts: 1,826
website/coding help
    #6165011 - 10/13/06 07:46 AM (5 years, 7 months ago)

I'm helping my uncle a little bit on his website but I'm not very good at coding/website work.  What he wants is a form that will send an email to his address after the form is filled out.  He wants visitors to his site to put their Name, Location, and a box where they can put some additional information if they want; he also wants a button where they can attach a file that will send with the email after they submit the form.

Is it possible to have a form with file attachment on a site that automatically sends the info filled out along with the file attachment.  If anyone can help me out I would really appreciate it.  I would be willing to paypal you 20 bucks if you help me figure this out. Thanks! :laugh:


Post Extras: Print Post  Remind Me! Notify Moderator
InvisibleYthanA
٩(●̮̮̃•̃)۶
Male

Folding@home Statistics
Registered: 08/08/97
Posts: 14,936
Loc: NY/MA/VT Border Flag
Re: website/coding help [Re: Trav]
    #6165196 - 10/13/06 09:06 AM (5 years, 7 months ago)

Here's a very easy way to set up a comment form on any web page:

Code:
<form method="post" action="mailto:yourname@yoursite.com" enctype="text/plain">
Your e-mail:<br> <input type="text" name="email"><br><br>
Your comments:<br> <textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit Your Comments">
</form>



However, it doesn't support file attachments and it doesn't work in all browsers. What you will probably need is a script to handle the form input.

First create an HTML page for the form:

form.html
Code:
<form method="post" action="send.php" enctype="multipart/form-data">
Your e-mail:<br> <input type="text" name="email"><br><br>
Your comments:<br> <textarea name="comments"></textarea><br><br>
Attachment?<br> <input name="attachment" type="file"><br><br>
<input type="submit" value="Submit Your Comments">
</form>



Then make a script to handle it:

send.php
Code:
<?
$file = fopen($_FILES['attachment']['tmp_name'],'rb');
$data = fread($file,filesize($_FILES['attachment']['tmp_name']));
fclose($file);
unlink($_FILES['attachment']['tmp_name']);
$data = chunk_split(base64_encode($data));

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers = "From: ".$_POST['email'];
$headers .= "\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"{$mime_boundary}\"";

$email_message = $_POST['comments']."\n\n";
$email_message .= "--{$mime_boundary}\nContent-Type:text/html; charset=\"iso-8859-1\"\nContent-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";
$email_message .= "--{$mime_boundary}\nContent-Type: {$_FILES['attachment']['type']};\n name=\"{$_FILES['attachment']['name']}\"\nContent-Transfer-Encoding: base64\n\n" . $data . "\n\n--{$mime_boundary}--\n";

$ok = @mail("youremail@host.com", "Feedback", $email_message, $headers);

if ($ok) {
echo "Your feedback was sent.";
} else {
die("Sorry but the email could not be sent.");
}
?>



Untested but should work. Hope this helps!

-Y


Post Extras: Print Post  Remind Me! Notify Moderator
InvisibleTrav
Stranger

Registered: 06/09/05
Posts: 1,826
Re: website/coding help [Re: Ythan]
    #6166815 - 10/13/06 05:27 PM (5 years, 7 months ago)

Thanks a lot! The code works perfect except when an image is sent as an attachment it only partially transfers. Any idea on how to fix that? Thanks again man, I appreciate it.


Post Extras: Print Post  Remind Me! Notify Moderator
InvisibleYthanA
٩(●̮̮̃•̃)۶
Male

Folding@home Statistics
Registered: 08/08/97
Posts: 14,936
Loc: NY/MA/VT Border Flag
Re: website/coding help [Re: Trav]
    #6168945 - 10/14/06 11:39 AM (5 years, 7 months ago)

Hmmm, good question. I just tested it using a JPEG and it worked fine. Want to try http://www.shroomery.org/ythan/form.html to make sure it's not a server problem? (It'll send to your Comcast e-mail.) You might need to bump up your upload_max_filesize or post_max_size in php.ini.


Post Extras: Print Post  Remind Me! Notify Moderator
InvisibleTrav
Stranger

Registered: 06/09/05
Posts: 1,826
Re: website/coding help [Re: Ythan]
    #6170480 - 10/14/06 10:33 PM (5 years, 7 months ago)

That fixed it, thank you so fucking much! You really helped me out.


Post Extras: Print Post  Remind Me! Notify Moderator
InvisibleYthanA
٩(●̮̮̃•̃)۶
Male

Folding@home Statistics
Registered: 08/08/97
Posts: 14,936
Loc: NY/MA/VT Border Flag
Re: website/coding help [Re: Trav]
    #6171772 - 10/15/06 12:10 PM (5 years, 7 months ago)

Sweet! Glad I could help. Good luck with your uncle's site.

-Y


Post Extras: Print Post  Remind Me! Notify Moderator
Jump to top. Pages: 1

General Interest >> Science, Technology & Computers

Similar ThreadsPosterViewsRepliesLast post
* Best program for the beginner website developer? SuperD 353 4 03/13/08 07:33 AM
by Legend9123
* Learning to create websites? DistortedEyes 401 13 10/31/05 01:25 PM
by ThePredator
* Writing a website
( 1 2 all )
Ego Death 1,104 23 02/26/07 03:59 PM
by SymmetryGroup8
* website help
( 1 2 all )
JESUS CLAUSE 632 27 01/22/09 01:19 PM
by zouden
* building a website LethalX5 388 7 03/17/05 03:00 AM
by phishman
* Modern website design TheCow 428 7 04/04/08 06:48 AM
by tak
* Anybody know of websites with "daily puzzles" that can be linked to and displayed on a web page? mushroomhunter10 206 3 12/04/08 10:59 AM
by legallyhomeless
* The Best Website Language? Earth_Droid 418 3 02/02/03 08:00 AM
by minusrestraint

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: Lana, trendal, Diploid, koraks, automan, johnm214
12,836 topic views. 0 members, 2 guests and 0 web crawlers are browsing this forum.
[ Toggle Favorite | Print Topic ]
Search this thread:
The Hawk&#039;s Eye
Please support our sponsors.

Copyright 1997-2012 Mind Media. Some rights reserved.

Generated in 0.244 seconds spending 0.181 seconds on 17 queries.