html - How do I import text from a user generated .txt-file to a div with PHP? -
this first experience php, bare me.
i've made ecard using flash , dreamweaver. on ecard form fill out, name, email, comment, , name , email person sending ecard to. (http://ornryd.com/test/playfulform/) when push "submit"-button sends email receiver, , creates .txt file on server info.
the .txt-file has unique name generated by:
$mailcount = $_post['me_count']; $sendername = $_post['me_name']; $senderemail= $_post['me_email']; $sendercomm = nl2br($_post['me_com']); $date = date("l js f h:i:s"); $tosubject = "email $sendername via $webname"; $emailbody = ""; $emailcount = 0; $createecard = date(u); $filename = $createecard.".txt"; $sendername = stripslashes($fromname); $sendercomm = stripslashes($sendercomm); $id = stripslashes($id); $today = (date ("l ds of f y ( h:i:s )",time())); $created="ecard created on $today"; $ecardnum = $ecardselect; $ecardtext = "&sendername=$sendername&fromemail=$fromemail&comment=$sendercomm&created=$created"; $fp = fopen( "./formtext/$filename","w"); fwrite($fp, $ecardtext, 10000); fclose( $fp );
in email there's link "page2" want comment form display in or in flash-text field, (http://www.ornryd.com/test/player/index.php)
the problem don't know how import user generated text in .txt-file div on page 2..
i hope understand want do. if not, can try describe things don't understand bit more.
thank you
//robert
you'll need send filename in link param. , php file need read param, , open appropriate file.
something along likes of
the link http://www.ornryd.com/test/readcard?file=afilename.txt
and php
$filename = isset($_get['file']) ? $_get['file'] : ''; $card = ''; if (file_exists($filename)) { $card = file_get_contents($filename); }
now have card contents variable, can display wherever want.
note example. few things have keep in mind
this allow people @ other files unless send kind of security token (people can change file @ else's card)
you should sanitizing filename bit path of file points directory want. remove stuff '../' in path.
Comments
Post a Comment