DarkKman Posted January 7, 2008 Share Posted January 7, 2008 Hi. I have created a page which simply creates a unique ref (sequential) in order to paste into emails so these can be tracked by my team. However I would like to add a way of prefixing the ref with a UserID so that I can see who's emailing etc. At the present the php is as follows (very basic I know - I am very much the novice): <?php $filename= "counter.txt" ; $fd = fopen ($filename , "r") or die ("Can't open $filename") ; $fstring = fread ($fd , filesize ($filename)) ; echo "IOM Reference: IOM$fstring" ; fclose($fd) ; $fd = fopen ($filename , "w") or die ("Can't open $filename") ; $fcounted = $fstring + 1 ; $fout= fwrite ($fd , $fcounted ) ; fclose($fd) ; ?> Obviously the "IOM Reference: IOM" is static text however what I would like is something like: echo "IOM Reference: $userid$fstring" ; I am assuming this would mean creating some sort of login however I don't care about validation of security. I just need a front page that a user can type their UserID into which could then be passed into the Reference. Can anyone help or advise? Quote Link to comment Share on other sites More sharing options...
duclet Posted January 7, 2008 Share Posted January 7, 2008 If you want it to be that simple, just have them like you say fill out a form and have that form submit to this page. Then you can change that line to 'IOM Reference: '.$_POST['userid'].$fstring; Quote Link to comment Share on other sites More sharing options...
adam291086 Posted January 7, 2008 Share Posted January 7, 2008 I am persuming you have a database full of cumstomer. You need a database connection and a query. Get all the Id from the database and set them into a variable. Then while there is information echo $id Quote Link to comment Share on other sites More sharing options...
DarkKman Posted January 7, 2008 Author Share Posted January 7, 2008 Thanks for the above guys... OK... So I now have two pages: tempref1.php: <form action="http://www.retina2.co.uk/iom/tempref2.php" method="POST" enctype="multipart/form-data" name="PostUserID"> Select UserID: <select NAME="ID" SIZE=1> <option selected value='1'>ASH<option value='2'>DPA<option value='3'>JRA<option value='4'>JHA<option value='5'>PMU<option value='6'>LCA<option value='7'>EBA<option value='8'>MDV<option value='9'>ALA<option value='10'>BBY<option value='11'>DTA<option value='12'>SBA </select> <input type="submit" value="Next"> </form> This contains my list of UserIDs which I want appended in the ref on the next page... tempref2.php: <?php $filename= "counter.txt" ; $fd = fopen ($filename , "r") or die ("Can't open $filename") ; $fstring = fread ($fd , filesize ($filename)) ; echo "IOM Reference: IOM$fstring.$_POST['ID']." ; fclose($fd) ; $fd = fopen ($filename , "w") or die ("Can't open $filename") ; $fcounted = $fstring + 1 ; $fout= fwrite ($fd , $fcounted ) ; fclose($fd) ; ?> But when I click 'Next' rather than see the "IOM Reference: IOMxxxxxxUserID" I get the below error: "Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/darkkman/retina2.co.uk/iom/tempref2.php on line 28" I know its probably something glaringly obvious but I am a certified noob so if anyone can point out my mistake I would be very grateful... Quote Link to comment Share on other sites More sharing options...
duclet Posted January 8, 2008 Share Posted January 8, 2008 Change this line echo "IOM Reference: IOM$fstring.$_POST['ID']." ; to echo "IOM Reference: IOM{$fstring}.{$_POST[iD]}." ; Quote Link to comment Share on other sites More sharing options...
DarkKman Posted January 8, 2008 Author Share Posted January 8, 2008 I am a plonker... D'oh... Thanks... You have been great. All sorted... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.