Page 1 of 1

Passing something through POST without involving the client

Posted: Sat Apr 26, 2003 6:29 am
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?

Posted: Sat Apr 26, 2003 6:37 am
by patrikG
You may want to use sessions - set userID as session-variable.

Posted: Sat Apr 26, 2003 6:56 am
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.

Posted: Sat Apr 26, 2003 8:43 am
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.

Posted: Sat Apr 26, 2003 11:25 am
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

Posted: Sat Apr 26, 2003 9:17 pm
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.

Posted: Sun Apr 27, 2003 8:28 am
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