Click to See Complete Forum and Search --> : Hiding variables passes in with URL?
tobyw_1969
07-04-2003, 10:54 AM
I've been learning PHP for 3 hours, so please fogive me for asking this question if it's really basic.
I'm trying to make a hi-score table which will appear in a PHP page, but using a score from a Flash game.
So far I've managed to set up my PHP pag so that it will display the hi-scores based on a variable called $score. I can pass the value of the player's score into this page by calling the URL like this from Flash
getURL("http://www.hostname.com/hiscore.php?score="+myScore);
But what this does is show the URL in the browser like this
.http://www.hostname.com./hiscore.php?score=1440
This means anyone could easily just type in the URL with any score they want.. so how can I call the PHP page WITHOUT showing the variable being passed into it?
Thanks a lot for your help on this
Rather than using the GET method, make a hidden form in your Flash file, that will submit a form to the PHP file via the POST method.
[J]ona
tobyw_1969
07-04-2003, 11:30 AM
Thanks - I will try that.
Is there a way to show a URL link in an e-mail that will also hide the variables?
I am thinking of the example of an e-greetings card, where you would want to send the recipient an e-mail something like
You have received a new card from .... Please click on this link to view your card
http://www.myhost.com/greetings.php?card=card1&message=happy birthday
Is there a better way to do that? Should I use POST there too? And how would it work?
I'm a bit confused about how to pass variables into the actual php page!
Thanks
Okay, to retrieve the POST variables, you'll use the following code:
echo $_POST['score'];
As for your e-card thing, I don't know if you could use the POST method there, since it's cross-server... Your link in the email would look something like this (assuming you're going to have different types of emails):
http://www.yourserver.com/greetings.php?greeting=Happy,%20Birthday&type=birthday
I don't know if you're going to dynamically generate a Flash file, or just edit it via PHP; but the easiest way would be to create a text file and edit it via PHP, then read from it in the Flash file--you can have multiple types based on which Flash file is displayed--in the above it'd be "birthday.swf," for example.
Let me know if you need any help on the PHP coding.
[J]ona
tobyw_1969
07-05-2003, 08:10 AM
Thanks for your help Jonah.
I've got the e-card thing up and running now, you can see it here
My card site (http://www.netcartoon.net/greetings/greetings-choose.htm)
The way I am doing it at the moment is not very good though, because the e-mail which goes to the recipient will have to contain a URL which includes all the variables, including the message etc.. which doesn't look too good.
I think your idea re: text file will be the best bet, but I am guessing a database will be better?
I've only been learning PHP for a day and a half, so my next objective will be to learn how to tie in with MySQL - but it looks quite frightening!
Anyway, thanks for your help - I expect I will be back with more questions soon... :)
Connecting to a database is quite simple really--setting up one, on the other hand, is the real challenge (it was on my first time, anyway). But you should use a database rather than a plain text file, because it is more secure and, in some cases, easier to manipulate the data.
[J]ona