Passing something through POST without involving the client

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CGameProgrammer
Forum Newbie
Posts: 11
Joined: Sun Mar 09, 2003 11:26 pm

Passing something through POST without involving the client

Post by CGameProgrammer »

On my site when you create a post or you write a comment, the script redirects to a purely server-side script that creates the HTML then redirects to the main page. The HTML-creating script sends nothing to the client so the user isn't even aware it's being called.

When something is posted, it redirects specifically to "index.php?View=##" where ## is the post ID number. This command shows that post (they're invisible initially).

But the problem of using the get method ("?View" in the URL) is that people can see it, and the problem with that is that they assume they can link to their post by copying that URL, which is incorrect. I want to hide View by using the Post method but don't know if I can do that, or how, using just a server-side script and no client-side stuff.

I know how to do it using the client; I can have an HTML form and use JavaScript to "submit" that form the instant the page loads. But I don't want any page to load. Am I making sense?
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You may want to use sessions - set userID as session-variable.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

So, if i understeand it correct.

You want, when a user post something, to give this user a url. So they can view there post anytime?

If this is the case, you can generate a random string. And parse this into the link, no id's. This same string will be saved into the database.

So the users can view there post, and they cannot gus what the link of a other user is.
CGameProgrammer
Forum Newbie
Posts: 11
Joined: Sun Mar 09, 2003 11:26 pm

Post by CGameProgrammer »

patrikG: Session variables are a good idea. Each user can have a variable saying which post they should view when the page loads... yeah, that'll work. Thanks!

inter: No. Say you go to the site devimg.net/index.php. That page will load the five most recent posts. Now you upload screenshots of your landscape engine, or whatever. You are redirected back to index.php?View=136 which will again load the five most recent posts (yours and four others) and the View command will scroll or show your post. This is a convenience measure so you don't have to click to open it yourself.

You might assume the URL devimg.net/index.php?View=136 can always be used to view your post. This is wrong. It will only show your post IF it's one of the five most recent posts; otherwise it won't be shown. So View is not a permanent link. But if View is hidden then since obviously copying the url "index.php" won't link specifically to your post, you'll look around and hopefully spot the "link" button (I'll try to make it more noticeable too).

That is what I was talking about.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

If you still want to 'POST' the data. Look at this link, My code at the bottom allows php to simulate a form post.

viewtopic.php?t=7063
CGameProgrammer
Forum Newbie
Posts: 11
Joined: Sun Mar 09, 2003 11:26 pm

Post by CGameProgrammer »

I couldn't get your code to work, hedge... interesting idea though, I'll keep it in mind. But session variables worked fine.
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

i recommend using sessions
here is an example page

Code: Select all

<?php
session_start();
$_SESSION['ViewId'] = $id;//// some value from database


?>
you have to included the session_start on every page you want this value referenced, it might also be usefull to check that the viewid exists on each page
Post Reply