Jump to content

[SOLVED] $page == "update" or "new" HELP???


Presto-X

Recommended Posts

How would I do this, I'm trying to use if something or something do the same thing with out having to put all the same code in twice.

 

if ( $page == "update" or "new" ){echo "Saving...";}

 

I have been fooling around with this for a day and it is driving me nuts I did not know what to search for I was not coming up with anything of any use. I tride:

 

$page == "update","new"
$page == "update" or "new"
$page == 'update' or 'new'

Link to comment
https://forums.phpfreaks.com/topic/46519-solved-page-update-or-new-help/
Share on other sites

Thank you guys so much it looks like it is working great now, I'm going back cleaning out alot of the if and elses in there lol thanks guys.

 

Hay Caesar what do you mean by "register_globals will be set" ? I'm new to php and I'm still learning all of the terms.

If you're sending values using urls such as:

 

http://somesite.com/index.php?page=pr0n

 

Then you want to make sure that you retrieve the values by using $_GET, instead of writing your code to look for $page. When you do that, you're asuming the server the site is on, has register_globals set to "on". And once you move your script somewhere else, it's likely it will stop working.

 

So your code should look something like:

 

<?php

  $page = $_GET['page'];

  if (($page == 'pr0n') | ($page == 'nekkid')) {

  echo'You dirty dirty boy...*snicker*';

  }

?>

 

Good luck and happy coding!

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.