Jump to content

[SOLVED] Add User Specific Prefix to a Unique Ref


DarkKman

Recommended Posts

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?  :)

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... :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.