Home | Community | Message Board

Cannabis Seeds UK
This site includes paid links. Please support our sponsors.


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!

Shop: Kraken Kratom Red Vein Kratom   Myyco.com Golden Teacher Liquid Culture For Sale

Jump to first unread post Pages: 1
InvisibleTrav
Stranger

Registered: 06/09/05
Posts: 1,826
website/coding help
    #6165011 - 10/13/06 08:46 AM (17 years, 5 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:

Extras: Filter Print Post Top
OfflineYthanA
ᕕ( ᐛ )ᕗ
Male User Gallery

Registered: 08/08/97
Posts: 18,817
Loc: NY/MA/VT Borderlands Flag
Last seen: 2 hours, 57 minutes
Re: website/coding help [Re: Trav]
    #6165196 - 10/13/06 10:06 AM (17 years, 5 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

Extras: Filter Print Post Top
InvisibleTrav
Stranger

Registered: 06/09/05
Posts: 1,826
Re: website/coding help [Re: Ythan]
    #6166815 - 10/13/06 06:27 PM (17 years, 5 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.

Extras: Filter Print Post Top
OfflineYthanA
ᕕ( ᐛ )ᕗ
Male User Gallery

Registered: 08/08/97
Posts: 18,817
Loc: NY/MA/VT Borderlands Flag
Last seen: 2 hours, 57 minutes
Re: website/coding help [Re: Trav]
    #6168945 - 10/14/06 12:39 PM (17 years, 5 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.

Extras: Filter Print Post Top
InvisibleTrav
Stranger

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

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

Extras: Filter Print Post Top
OfflineYthanA
ᕕ( ᐛ )ᕗ
Male User Gallery

Registered: 08/08/97
Posts: 18,817
Loc: NY/MA/VT Borderlands Flag
Last seen: 2 hours, 57 minutes
Re: website/coding help [Re: Trav]
    #6171772 - 10/15/06 01:10 PM (17 years, 5 months ago)

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

-Y

Extras: Filter Print Post Top
Jump to top Pages: 1

Shop: Kraken Kratom Red Vein Kratom   Myyco.com Golden Teacher Liquid Culture For Sale


Similar ThreadsPosterViewsRepliesLast post
* Best email program? zorbman 995 15 02/07/08 11:51 AM
by beatyou
* anyone else here code for a living?
( 1 2 all )
BrAiN 2,815 21 01/08/08 03:35 PM
by Diploid
* NSA Bugged Website Visitors Despite Ban DiploidM 536 0 12/31/05 06:50 PM
by Diploid
* Learning to create websites? DistortedEyes 1,062 13 10/31/05 02:25 PM
by ThePredator
* Writing a website
( 1 2 all )
Ego Death 2,266 23 02/26/07 04:59 PM
by SymmetryGroup8
* How do i get an IP from an email? RESET32one 1,479 5 05/22/02 01:12 AM
by Lana
* Junk Emails Full of... something... fireworks_godS 1,648 11 11/30/03 09:01 PM
by
* hosting a website
( 1 2 all )
funkymonk 2,512 23 03/19/05 08:08 PM
by kadakuda

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
13,258 topic views. 0 members, 0 guests and 3 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.023 seconds spending 0.007 seconds on 14 queries.