PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Jun 05, 2020 1:25 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Simple coding help?
PostPosted: Sun Feb 12, 2012 5:39 pm 
Offline
Forum Newbie

Joined: Sun Feb 12, 2012 5:18 pm
Posts: 1
Hey guys X) another PHP noob is looking for a bit of help!

The concept: I want to set up a website that is a series of riddles. From the start page, you have to enter a set password to get to the next page, which will have a different riddle, and a different password.

a couple of the pages:
Syntax: [ Download ] [ Hide ]
<p> To continue, you must know. </p>

<form action="/answer.php" method="post">
 <input type="text" maxlength="22" name="key" />
 <input type="hidden" name="correctkey" value="ANSWER HERE" />
 <input type="hidden" name="page" value="NAME OF CURRENT PAGE.PHP" />
 <input type="hidden" name="nextpage" value="NAME OF NEXT PAGE.PHP" />
 <input type="submit" value="GO" />
</form>

 


The above is just a quick excerpt, but the rest of the page is text and formatting.

answer.php is:

Syntax: [ Download ] [ Hide ]
<html>
<?php
$key = $_POST['key'];
$correctkey = $_POST['correctkey'];
$page = $_POST['page'];
$nextpage = $_POST['nextpage'];

if ($key==$correctkey)
  header ("Location: $nextpage");
else
  header ("Location: $page");
?>
</html>


Functionally, it's really simple. But the problem i'm facing is in keeping the passwords for each page out of the source. I've been able to make the site behave as expected, but I can't seem to keep the passwords away from the watchful eyes of Google chrome's 'inspect element' function, even if I Include() the form code instead. Maybe i didn't use it right? :?:
In actuality, it isn't a huge matter of security, but I would really appreciate if I could make it so that you couldn't just right-click the page and find out the answers! XP


Top
 Profile  
 
 Post subject: Re: Simple coding help?
PostPosted: Sun Feb 12, 2012 9:22 pm 
Offline
Jack of Zircons
User avatar

Joined: Thu Nov 09, 2006 9:30 pm
Posts: 4484
Location: California, USA
The user will always be able to see the HTML in the source view, so you don't want to use that for storing anything you don't want the user to see, regardless of any PHP techniques, since that's all done before the page is sent to the browser. This is a job for Session variables. Read up on them: (the official explanation) and/or (tutorial, easier to read).


Top
 Profile  
 
 Post subject: Re: Simple coding help?
PostPosted: Mon Feb 13, 2012 2:29 am 
Offline
DevNet Resident
User avatar

Joined: Sun Sep 03, 2006 5:19 am
Posts: 1579
Location: Sofia, Bulgaria
Also, an easier way would be to use a bit of javascript to send the user to <password>.html which is the next level of the game.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group