LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2013, 07:37 PM   #1
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
Create unique temporary file name


If I have this hidden line in a form action function, will 'id' be sent to "do_whatever.php".

Code:
<form action="do_whatever.php" method="get">
 <input blah blah blah>
 <input blah blah blah>
 <input blah blah blah>
 <input type="hidden" name="id" value="<?=uniqid('', true)?>" />
 <input type="submit" value="Submit" />
</form>
Then in "do_whatever.php" I can:
Code:
$tempIDnumber = $_GET['id'];\
And do whatever I require with that number.

I'm reading from
http://stackoverflow.com/questions/5...ue-id-with-get

I read several other Google places, they said: a) This could not be done. b) This was not the way to do this but gave no alternative.
Then I found this which seems reasonable.

So I asking the question my self.
 
Old 12-02-2013, 07:53 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
I'm not sure it's all that reasonable to trust data being (re-)posted from a hidden input in a form. Wouldn't it mean that someone could post a form to do_whatever.php with an "id" value of their choosing and cause all kinds of trouble, including overwriting date generated by another session, or ever worse, gain access to data from another (perhaps authenticated) session?

(Disclaimer: Yes, I've done exactly this to fool a web application into believing I had a valid session when in fact I did not. I am not responsible for any legal trouble anybody may get into should they choose to do something similar.)

If the idea is simply to generate a unique temporary file, wouldn't using tempnam be a better and safer approach?

Last edited by Ser Olmy; 12-02-2013 at 07:55 PM.
 
Old 12-03-2013, 05:12 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Methinks $_SESSION would be a better space to store session-specific data.
 
Old 12-03-2013, 02:59 PM   #4
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
Quote:
Originally Posted by Ser Olmy View Post
If the idea is simply to generate a unique temporary file, wouldn't using tempnam be a better and safer approach?
I did not find how many entities tempnam can have in existence at one time. Would 2000 plus be unrealistic? How many unique file names could it produce in 1 second?

What I want to do:
a) Person comes to website, Enters date, city, state, which is sent via a 'form action' to a function.
b) Function sends to another function which, creates a 'unique file name' and sends this 'unique file name' along with 'date, city, state' to another file.
c) Another file searches for the closest 50 towns to 'city, state', writes them to 'unique file name' pre-pending the date.
d) A search function uses the information created by 'Another file' to search a large data base for matches.
Printed to the screen, it might look something like this.
Quote:
07/21/2013,Houston, TX,Raina rose,artistwebsite.html,venuewebsite.html
07/21/2013,The Woodlands, TX,Rebecca Loeby,artistwebsite.html,venuewebsite.html
07/21/2013,Huntsville, TX,Kacie Jones,artistwebsite.html,venuewebsite.html
07/21/2013,Galveston, TX,Susan Gibson,artistwebsite.html,venuewebsite.html
When everything has been written to the screen, 'unique file name' is removed.
 
Old 12-05-2013, 10:55 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
That's what $_SESSION is good for.
 
Old 12-08-2013, 02:24 AM   #6
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
Quote:
Originally Posted by NevemTeve View Post
That's what $_SESSION is good for.
After thinking about this and doing some Google search, I probably should go this route.

I need to get on the learning curve truck again. I will close this thread out and start a new one next week.

Thanks for getting me headed in the right direction.
Dave
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Create Temporary directory and file in one go .......... prravin1 Programming 8 03-07-2012 07:04 AM
pwmconfig Cannot create temporary file?!? dangerousdave Linux - Software 1 05-01-2006 07:27 PM
Problem with lpr - cannot create temporary file fclifton Linux - General 3 09-18-2004 04:43 PM
mogrify: Unable to create temporary file. steelgrave Linux - Software 5 05-31-2003 05:46 PM
ERROR: Couldn't create temporary file in /tmp/ bananaman Linux - Newbie 5 04-09-2003 09:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration