FilipKrstic Posted January 6, 2009 Share Posted January 6, 2009 I need to make page, which is order by id, and she need to has a cases? For example... http://www.mysite.com/page.php?id=1 and I have "switch ($_REQUEST[alpha]) { case downloads: break; }" Link for this `ll be http://www.mysite.com/page.php?id=1?alpha=downloads but that can`t.... Can someone help? Thanks a lot... Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/ Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 It should be page.php?id=1&alpha=downloads. Unclear on what your actual question is, but show some actual code if that does not answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730469 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 but that can`t.... Huh? What's your problem? Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730477 Share on other sites More sharing options...
redarrow Posted January 6, 2009 Share Posted January 6, 2009 php? <<< add some think else id=1 & <<< and another alpha=downloads Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730478 Share on other sites More sharing options...
FilipKrstic Posted January 6, 2009 Author Share Posted January 6, 2009 Thanks... That`s enough... Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730480 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 You first need to fix what premiso mentioned, but something like this? $i = $_GET['id']; switch ($i) { case 0: echo "i equals 0"; break; case 1: echo "i equals 1"; break; case 2: echo "i equals 2"; break; } Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730482 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 Same with strings... Look in the manual... "http://www.mysite.com/page.php?id=1&alpha=downloads" $i = $_GET['alpha']; switch ($i) { case "downloads": echo "Yay! downloads"; break; case "uploads": echo "uploads"; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730485 Share on other sites More sharing options...
FilipKrstic Posted January 6, 2009 Author Share Posted January 6, 2009 Huh, guys many helpful informations.. Amazing... I have one more question, and I can start with writing... I have two sessions... Session $_SESSION[username] and $_SESSION[mcp]. At the start I have classic if... session_start(); require_once("../config.php"); // Check his status. if (!empty($_SESSION[mcp]) or ($_SESSION[username])) { // There is place where I need to put loggin function... } else // bad info { echo "Need to login first"; } And I don`t how to make fuction logged? "if user logged as $_SESSION[username] print Welcome $_SESSION[username] or if logged as $_SESSION[mcp] print Welcome $_SESSION[mcp]" ??? P.S I`m php starter... Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730495 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 session_start(); require_once("../config.php"); if(isset($_SESSION['mcp']) || isset($_SESSIONS['username' ) { echo "Welcome " . $_SESSIONS['username'] . " "; echo "What is mcp? " . $_SESSIONS['mcp'] . " "; } else { echo "Need to login first"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730504 Share on other sites More sharing options...
FilipKrstic Posted January 6, 2009 Author Share Posted January 6, 2009 When I try this peace of code, and when I login as $_SESSION[username], server shows me: "Need to login first", missing _$SESSION[bla] OR _$SESSION_[blabla]... Maybe: <?php session_start(); require_once("../config.php"); // Check his status. if (isset($_SESSION[mcp]) or isset($_SESSION[username])) { ?> ? What is ||? Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730519 Share on other sites More sharing options...
Maq Posted January 6, 2009 Share Posted January 6, 2009 Where do you set the session? When you login you should set the session, like: $_SESSIONS['username'] = "FilipKrstic"; Can you post your code too? Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730520 Share on other sites More sharing options...
FilipKrstic Posted January 6, 2009 Author Share Posted January 6, 2009 Here we are... Session username is session for admin and mcp is session for moderator_control_panel. And I want make that the admin can come in mcp with his login (with his session). That is the reason why I put OR. Informations about $_SESSIONS['username'] comes from mysql, table admins, and $_SESSIONS['mcp'] from mysql too, table mods... Code for mcp page... <?php session_start(); require_once("../config.php"); // Check his status. if (!empty($_SESSION[mcp]) or ($_SESSION[username])) { // MOD AREA } else // bad info { echo "Need to login first"; } ?> Login page... <?php session_start(); // Check if he wants to login: if (!empty($_POST[mcp])) { require_once("../config.php"); // Check if he has the right info. $query = mysql_query("SELECT * FROM mods WHERE username = '$_POST[mcp]' AND password = '$_POST[password]'") or die ("<Wrong username or password"); $row = mysql_fetch_array($query) or die ("Wrong username or password"); if (!empty($row[username])) // he got it. { $_SESSION[mcp] = $row[username]; echo "Success"; exit(); } else // bad info. { echo "Please login"; exit(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-730525 Share on other sites More sharing options...
FilipKrstic Posted January 7, 2009 Author Share Posted January 7, 2009 heh... Solved with classic if, again... <?php if(isset($_SESSION['mcp'])) { print"Wlc Mod"; } if(isset($_SESSION['username'])) { print"Wlc Adm"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-731297 Share on other sites More sharing options...
Sesquipedalian Posted January 7, 2009 Share Posted January 7, 2009 If you dont know something like || or manipulating GET variables you should probably take a look at a beginner PHP tutorial -- it'll make the things you're trying to do much easier. Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-731337 Share on other sites More sharing options...
Maq Posted January 8, 2009 Share Posted January 8, 2009 || = OR Quote Link to comment https://forums.phpfreaks.com/topic/139621-how-to-use-id-and-cases/#findComment-732095 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.