Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-23-2005, 10:35 AM
WebProWorld Member
 

Join Date: Aug 2004
Location: England
Posts: 66
Biggles RepRank 0
Default Form to Email with attachments script

Hello all, Iam having trouble getting a form to email script that will handle users sending me a file such as a picture.

I found this script http://obiewebsite.sourceforge.net/o...ith_attachment that looked like it would do exactly what i wanted but when i upload it and set the chmod as the instuctions say it dosent work ! his demo one seems to , Anyone see whats wrong with it?

Or, has anyone got a better one ?

P.s. i dont speak php !
Reply With Quote
  #2 (permalink)  
Old 03-24-2005, 12:09 AM
mikmik's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 3,406
mikmik RepRank 1
Default

Hi, Biggles. I don't speak it either, but I get many, many scripts from here. I have found that sometimes I will try several before I get one to work properly.

I haven't used a form that handles attatchments, so I don't have a good one I've tried, but the one called aMAILzing here at www.hotscripts.com looks good.

It is a primary place I look for scripts - they are rated and I like that.

This script looks straightforward, by the description.

Yes, the site has good support and explanations, and the download has a demo as well:
http://scripts.inexistent.org/amailzing/index.php
__________________
What I am is what I am, are you what you are, or what.
Eddie Brickel
Reply With Quote
  #3 (permalink)  
Old 03-24-2005, 09:47 AM
WebProWorld Member
 

Join Date: Aug 2004
Location: England
Posts: 66
Biggles RepRank 0
Default

Here is a post where i put all the script i was using.

Can anyone see a problem with it?

http://<br /> <a href="http://forum...=876</a><br />


Thanks for the heads up mikmik, i did look around hotsripts but i guess i didnt see that one, will give it a go, it' my 10th attempt to get this working ! lol
Reply With Quote
  #4 (permalink)  
Old 03-24-2005, 10:24 AM
WebProWorld Member
 

Join Date: Aug 2004
Location: England
Posts: 66
Biggles RepRank 0
Default

Thanks mikmik, this does look promising. I have tried it and it seems simple enough but i am getting these errors:

Quote:
Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not a valid IPv4 or IPv6 address in /home/wingsof/public_html/amailzing.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /home/wingsof/public_html/amailzing.php:97) in /home/wingsof/public_html/amailzing.php on line 212
The code that these refer to is:

Quote:

// Write the start of the email body.

$message = "The following form was sent to you from your website!\n";
$message .= "-----------------------------------------------------------\n";
$message .= "Ip: $REMOTE_ADDR\n";
(line97)-> $message .= "Host: ".gethostbyaddr($REMOTE_ADDR)."\n";
$message .= "Browser: $HTTP_USER_AGENT\n";
$message .= "Referrer: $HTTP_REFERER\n\n";


line 212:
header("Location: $ref?message=$thankyou");


Anyone know whats wrong?

When i remove all the $message junk i get the email, the header message appears etc, all works fine.

However, the image i attach does not get sent, it knows the filename but cant show an image. Is there a fix anyone can show me? Do i need to upload them to the server first? ie, to MySQL if so how do i do it?

I am using Cpanel if that affects it, it is quite possible !


cheers
Reply With Quote
  #5 (permalink)  
Old 03-25-2005, 08:05 AM
WebProWorld Member
 

Join Date: Aug 2004
Location: England
Posts: 66
Biggles RepRank 0
Default

i have the script suggested by mikmik and it works in-so-far as to send me an email with all info inputted, it doesnt attach the picture tho. I get the file name of the attachment, but not the actual file.

It has been suggested that it may be due to the servers register_globals being off.

here is the code for the php processing script:
Code:
<?php // Copyright ©2005, Christine M. R.

// To change the settings, simply change "email@email.com" to the email address
// you wish for the emails to be sent to, and "Thanks for your email, 
// I'll get back on you later!" to the confirmation message you want to be shown
// when everything is working just fine and the message was sent! :)
// Please avoid use of quoation signs. (")
$myemail = "

submit@wingsofwar.org.uk


"; $thankyou = "


Thank you for your submission to Wings of War. :)

";


// Don't edit anything below this line, unless you know what you are doing :)


// Make sure nobody gets stuck in infinite loops.

if(!$_POST)
	die('Please don\'t access this file directly.');


// Remove all those linebreaks from the variables.

$myemail = str_replace("
",'',$myemail); 
$thankyou = str_replace("
",'',$thankyou);


// Gather all the required fields. Remove the REQUIRED part from their names.

while(list($key,$val) = each($_POST)) {
	if(stristr($key,'REQUIRED')){
		$key = str_replace('REQUIRED','',$key);
		$_POST[$key] = $val;
		if($val == ''){
			$missing[] = ''.$key.'';
		}
	}
}


// If there is a myemail value in the form, send the email to it instead!

if($_POST[myemail])
	$myemail = $_POST[myemail];

// Set default values if there exists none.

if($_POST[name]){ $name = $_POST[name]; } else { $name = "aMAILzing"; }
if($_POST[email]){ $email = $_POST[email]; } else { $email = $myemail; }
if($_POST[subject]){ $subject = $_POST[subject]; } else { $subject = "Web Form"; }

// Find all the fields, and add them to the email.

foreach($_POST as $k=>$v) {
	if($v && !stristr($k,'REQUIRED'))
		if(is_array($v))
			$message .= ucfirst($k).": ".implode(', ', $v)."\n\n";
		else
			$message .= ucfirst($k).": $v\n\n";
}

// Write the rest of the email body.

$message .= "-----------------------------------------------------------\n";
$message .= "Powered by aMAILzing - http://scripts.inexistent.org";
$message = stripslashes($message);


// Write the headers.

$mail_boundary = "x".md5(time())."x";
$header = "From: $name <$email>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: multipart/mixed; boundary=\"{$mail_boundary}\"\r\n";
$header .= "X-Priority: 3\r\n";
$header .= "X-MSMail-Priority: Normal\r\n";
$header .= "X-Mailer: aMAILzing 0.9 http://scripts.inexistent.org\r\n";
$header .= "This is a multi-part message in MIME format.\r\n\r\n";
$header .= "--{$mail_boundary}\r\n";
$header .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
$header .= "Date: ".date(R)."\r\n";
$header .= "Content-Transfer-Encoding:7bit\r\n\r\n";
$header .= $message."\r\n\r\n";

// Attach the uploaded files, if there is any.

if($_FILES){

	if (get_magic_quotes_runtime() == 1){
		set_magic_quotes_runtime(0);
	}

	foreach($_FILES as $key=>$value){
		foreach($value as $key2 => $value2){
			$$key2 = $value2;
		}

		if (is_uploaded_file($tmp_name)) {    
			$fp = fopen($tmp_name,'rb');
			$read = fread($fp,$size);
			fclose($fp);

			$file = base64_encode($read);
			$file = chunk_split($file);

			$header .= "--$mail_boundary\r\n";
			$header .= "Content-type: $type; name=\"$name\"\r\n";
			$header .= "Content-Transfer-Encoding:base64\r\n";
			$header .= "Content-Disposition: attachment; filename=\"$name\"\r\n\r\n";
			$header .= $file."\r\n\r\n";
		}
	}
}

// Now, lets deal with what we've got so far!

$valid_email = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email);

if(!$missing && $valid_email) {
	mail($myemail,$subject,'',$header);
} elseif(!$valid_email){
	$thankyou = "Your email address doesnt seem to be valid - please doublecheck it.";
} else {
	if(count($missing)>1){
		$last = array_pop($missing);
		$themissing = implode(', ',$missing).' and '.$last;
		$plu = 's';
	} else {
		$themissing = $missing[0];
	}
	$thankyou = "Sorry, but you do not seem to have filled out the field$plu ".$themissing.". Please go back and fill out all the required fields!";
}


// And, in the very end, we've got to catch the referrers and redirect back to where we came from.

$ref = getenv("HTTP_REFERER");
$ref = explode('?',$ref);
$ref = $ref[0];

$thankyou .= ' Powered by aMAILzing.';

header("Location: $ref?message=$thankyou");


// And then, we're done!

?>
anyone know about phph? cuz i don't !

Thanks in advance
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
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


Search Engine Optimization by vBSEO 3.2.0