Jump to content

Where in a code?


Mikey3523

Recommended Posts

Hello,

 

I'm making a code where someone who types in a certain word, gets taken to another page which gives them a kind of 'clue' to something. What I was wondering is, where about in a php code would the part be where the forum recognises someone is using that specific word?

 

How would it look and any tips on how to set it up?

 

If someone could give me any help it would be much appreciated!

 

Thanks in advance!  :)

 

Mikey

Link to comment
Share on other sites

kk, lol my code would allow multiple codes, each with a file of there own, but if you only have 1 then use the code above

 

on the page

 

 

<form action="secret.php" method="post">
Enter Code: <input name="code" type="text" />
<input type="submit" value="Upload" />
</form>

 

 

secret.php

<? php

$code = $_POST["code"];
$page = $code.'.php';

if (file_exists($page))
{
include '$page';
}
else
{
include 'invalidcode.php';
}

?>

 

Then for code "elephant" you would make a page "elephant.php", for code "frog" you would make a page "from.php"

 

If you want the codepages to be html then change

 

$page = $code.'.php';

 

to

 

$page = $code.'.html';

Link to comment
Share on other sites

A form? Do you mean a posting form? If so, I already have one of them.

 

I'm not sure what you mean by only using one code. Basically, I want to set up a code which takes users to a different page when they type this specific word. Which code would I use for this out of the three you posted?

 

Thanks for helping aswell guys!  :)

Link to comment
Share on other sites

Yeah, use Stephen's if it's one word.  If it's more, make an array and use in_array().

 

@MadnessRed:  It's not secure, because what if their word was ../somefile?  Then they're at ../somefile.php.  You can't just "make sure the file exists and then send them there."

Link to comment
Share on other sites

Oh but if there word isn't correct, I dont want anything to show. Basically, it's just a normal post but if someone happens to use this word in any of their posts, they get taken to a page. I only want the forum to notice it if a user includes this word in their post. If they don't, then I just want things to carry on as normal. The users dont know this will be set up so it's kind of a surprise :P

Link to comment
Share on other sites

What do you mean by after I've put their code in the database?

 

So that code you just provided me with...if I use that, will it make it so that if this word is typed, they will be taken to the page I direct it to?

 

Also, how do I donate?  You've been a big help so if I solve this, I think I'll help out ;)

Link to comment
Share on other sites

You can donate to me via Paypal.  I'll PM you my PayPal e-mail if you want.

 

I mean that you don't want to redirect them before their post goes into the database.  You said this was a forum, right?  So therefore, you should place this AFTER the post is placed into the database.

Link to comment
Share on other sites

Yeah it's a forum but when you say after their post is placed into the database, where about should I put this code? I wont be able to be on 24 hours a day when everyone makes posts...

 

I might just be reading this wrong though lol. So where about would I put this code?

Link to comment
Share on other sites

Put it inside the script, but place it AFTER the code that does the post insertion.

 

I.E:

<?php

include ('somefile.php'); //example includes or w/e.

/*************************

*Here is where you insert it into the database

**************************/

//Here's where the redirection code goes

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.