ashlie Posted February 8, 2007 Share Posted February 8, 2007 Heya I'm fairly (er, very) new to PHP. I'm looking for a form that sends its information as an .txt attachment. I know how to make a php that sends its information in the body - but haven't had much luck on finding information how to send it as an attachment. Can it be done in php? If so, does anyone know how? Thanks in advance Ashlie Link to comment https://forums.phpfreaks.com/topic/37682-php-to-send-form-as-an-attachment/ Share on other sites More sharing options...
camdagr81 Posted February 9, 2007 Share Posted February 9, 2007 This should be around what you're trying to do <?php function new_file() { $cmd = $_POST['cmd']; $text = $_POST['data']; if ($text && $cmd == 'Post') { $dir = './files/'; $filename = time() . '.txt'; $newfile = $dir . $filename; $handle = fopen($newfile, 'a'); fwrite($handle, $text); fclose($handle); return "<a href='$newfile'>$filename</a>"; } } echo "<br>" . new_file(); ?> <form action="" method="post"> <textarea name="data"></textarea> <input type="submit" name="cmd" value="Post"> </form> Link to comment https://forums.phpfreaks.com/topic/37682-php-to-send-form-as-an-attachment/#findComment-181044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.