Dada78 Posted January 21, 2008 Share Posted January 21, 2008 I have been reading php.net and I think this is what I need but I am not sure and not sure how it works. In my user CP that will be restricted to regsitered members only has some navigation links that that you can see at http://mesquitechristmas.com/local/user.php Well I an trying to navigate between those links but I need it to look like this http://mesquitechristmas.com/local/user.php?action=edit But it brings up this page http://mesquitechristmas.com/local/edit.php And so on for the other two links etc. How do I go about doing this where I can bring up certain pages under user.php? Hope this makes sense. I am trying to get this nailed down so I can lock down the user CP but I need this ironed out before I can do that. -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/ Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 well your best option i believe is to use a switch command <?php $action = $_GET['action']; switch($action) { case "edit": include "edit.php"; break; case "logout": include "logout.php"; break; default : include "user.php"; } ?> Just place this code in the main contents area of your page, and just use the links /local/user.php?action=logout or /local/user.php?action=edit Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444761 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Ok thanks I will give that a try. Just a quick question. First, how do I echo this within HTML. Second, do I still need to put session start at the top of all those pages or just at the top of user.php? -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444765 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 just put the session start at the top of user.php and just put that switch where all your content will go. give it a go, it will take a bit of mucking around to get it all proper. I suggest for the default: to make a seperate page for it Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444770 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Ok I put that code in the top of my user.php and I get this error Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 384 bytes) in /home/mesquit1/public_html/local/user.php on line 5 Which is this line $action = $_GET['action']; Does this go just on the user.php correct? Is their a php way to call this in the link or just simply like this? <a href="user.php?action=editprofile">Edit Profile</a> -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444775 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Ok I keep playing with this but I am not sure where it goes. Can someone please help me with this. If I put it in the HTML of the user.php I just get unlimited template loading over and over again. If I put it at the top before the HTML I get the error above. If I put it on all the other pages when I click on a link of user.php the other pages don't come up but the URL shows correctly. What am I doing wrong and how is this suppose to work. -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444832 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 ok this is the thing with using the switch command. when including the files.. eg: edit,logout etc all those files need are the content, not the template. let me trying and explain to u in user.php this page should contain the hole template of the website, including navigations, headers, footers etc etc then using the switch command the pages that u include EG: case "edit": include "edit.php"; break; this page SHOULDN'T contain anything BUT content. Content such as a form that will be used when editing the user profile. I hope you understand, its fairly hard to explain Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444875 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 I understand what you are saying. I tried that but it still produced multiple pages. In my user.php I did this. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mesquite Texas Country Christmas" /> <meta name="keywords" content="Mesquite, Texas, Country Christmas" /> <meta name="author" content="NA" /> <link rel="stylesheet" type="text/css" href="/stylesheet.css" media="screen" title="FBC" /> <script type="text/javascript" src="drop_down.js"></script> <title>A Mesquite Country Christmas</title> </head> <body> <div id="wrap"> <a href="/index.html"> <img id="frontphoto" src="/images/header.png" width="760" height="237" alt="Mesquite Country Christmas" border="0"></a> <div id="menu"> <h2 class="hide">Menu:</h2> <ul id="avmenu"> <li><a href="/index.html">Home</a></li> <li><a href="/christmasstory.html">The Christmas Story</a></li> <li><a href="/directions.html">Directions</a></li> <li><a href="#">Information</a><ul> <li><a href="/information.html">Display Facts & Info</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/playlist.html">2008 Playlist</a></li> <li><a href="#">Christmas History</a></li> </ul></li> <li><a href="#">Photos</a> <ul> <li><a href="/2007photos.html">2007</a></li> </ul></li> <li><a href="#">Videos</a> <ul> <li><a href="/2007videos.html">2007</a></li> </ul></li> <li><a href="/guestbook.php">Guestbook</a></li> <li><a href="/webcam.html">Web Cam</a></li> <li><a href="/webradio.html">Internet Radio</a></li> <li><a href="http://www.noradsanta.org/" TARGET="_blank">Track Santa</a></li> <li><a href="/projects.html">Projects & How Tos</a></li> <li><a href="/links.html">Links</a></li> <li><a href="/contact_us.html">Contact Us</a></li> </ul> <center><a href="http://www.toysfortots.org/" TARGET="_blank"><img src="/images/toys_for_tots.jpg" border="0" width="110" height="153" vspace="10"></a></center> <center><a href="http://christmas.bronners.com/2007/house/534.html"><img src="http://christmas.bronners.com/voteforme/vote.jpg" border="0" width="110" height="153" alt="christmas decorations" vspace="10"></a></center> </div> <div id="content"> <div class="fadebox"> <h2> Your User Account</h2> <hr /> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="100%" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <td><a href="user.php?action=editprofile">Edit Profile</a> | <a href="submit.php">Add Entry</a> | <a href="user.php?action=edit">Edit Entries</a> | <a href="logout.php">Log Out</a></td> </tr> </table> </td> </form> </tr> </table> </td> </tr> <tr> <td> <?php $action = $_GET['action']; switch($action) { case "edit": include "editprofile.php"; break; case "logout": include "logout.php"; break; default : include "user.php"; } ?> </td> </tr> </table> </div> </div> </div> <div id="footer"> © 2007 Mesquite Country Christmas <br /> <br /> <script type="text/javascript"><!-- google_ad_client = "pub-8048181801684156"; //468x60, created 1/8/08 google_ad_slot = "0360766123"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444895 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 yeah ok i see what your doing, as default you are including user.php again you need to make a seperate page userindex.php <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="100%" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <td><a href="user.php?action=editprofile">Edit Profile</a> | <a href="submit.php">Add Entry</a> | <a href="user.php?action=edit">Edit Entries</a> | <a href="logout.php">Log Out</a></td> </tr> </table> </td> </form> </tr> </table> user.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Mesquite Texas Country Christmas" /> <meta name="keywords" content="Mesquite, Texas, Country Christmas" /> <meta name="author" content="NA" /> <link rel="stylesheet" type="text/css" href="/stylesheet.css" media="screen" title="FBC" /> <script type="text/javascript" src="drop_down.js"></script> <title>A Mesquite Country Christmas</title> </head> <body> <div id="wrap"> <a href="/index.html"> <img id="frontphoto" src="/images/header.png" width="760" height="237" alt="Mesquite Country Christmas" border="0"></a> <div id="menu"> <h2 class="hide">Menu:</h2> <ul id="avmenu"> <li><a href="/index.html">Home</a></li> <li><a href="/christmasstory.html">The Christmas Story</a></li> <li><a href="/directions.html">Directions</a></li> <li><a href="#">Information</a><ul> <li><a href="/information.html">Display Facts & Info</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/playlist.html">2008 Playlist</a></li> <li><a href="#">Christmas History</a></li> </ul></li> <li><a href="#">Photos</a> <ul> <li><a href="/2007photos.html">2007</a></li> </ul></li> <li><a href="#">Videos</a> <ul> <li><a href="/2007videos.html">2007</a></li> </ul></li> <li><a href="/guestbook.php">Guestbook</a></li> <li><a href="/webcam.html">Web Cam</a></li> <li><a href="/webradio.html">Internet Radio</a></li> <li><a href="http://www.noradsanta.org/" TARGET="_blank">Track Santa</a></li> <li><a href="/projects.html">Projects & How Tos</a></li> <li><a href="/links.html">Links</a></li> <li><a href="/contact_us.html">Contact Us</a></li> </ul> <center><a href="http://www.toysfortots.org/" TARGET="_blank"><img src="/images/toys_for_tots.jpg" border="0" width="110" height="153" vspace="10"></a></center> <center><a href="http://christmas.bronners.com/2007/house/534.html"><img src="http://christmas.bronners.com/voteforme/vote.jpg" border="0" width="110" height="153" alt="christmas decorations" vspace="10"></a></center> </div> <div id="content"> <div class="fadebox"> <h2> Your User Account</h2> <hr /> <?php $action = $_GET['action']; switch($action) { case "edit": include "editprofile.php"; break; case "logout": include "logout.php"; break; default : include "userindex.php"; } ?> </td> </tr> <tr> <td> </td> </tr> </table> </div> </div> </div> <div id="footer"> © 2007 Mesquite Country Christmas <br /> <br /> <script type="text/javascript"><!-- google_ad_client = "pub-8048181801684156"; //468x60, created 1/8/08 google_ad_slot = "0360766123"; google_ad_width = 468; google_ad_height = 60; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </body> </html> something like that neway, im not totally sure of the layout of your page, but what it will do is, when u load user.php it will automatically include userindex.php and if the html is all in the right order, it will sort itself out pretty nicely Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444897 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Ok thanks that made sense now. I tried that before but I guess I wasn't doing something right. One last thing I have have a question about that I am not sure how to do. This page right here http://mesquitechristmas.com/local/user.php?action=edit You will notice in the box that says "Edit This Display". When you click on it I need it to go to this page. http://www.mesquitechristmas.com/local/update.php It will pull up that form with the information in it by the id in the database. So can that switch function be used twice in and how? -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444927 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 if u ever want to add nething to that switch command all you need to add is another case: eg: case "changepassword" : include "changepw.php"; break; and then that will allow you to go ?action=changepassword for the db all you need to do is... ?action=edit&id=# # = the id number you need and then on the update.php page you just need to have $id = $_GET['id']; SELECT * FROM table WHERE id='$id' Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444934 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks for your help, yea I figured out adding a new case. So when I click on edit display it will go from this user.php?action=edit to this user.php?action=edit&id=322 taking me to the page form page above I listed earlier. Now when I add the query to the update.php page to pull up that form will it open it in user.php?action=edit&id= Or do I need to had the layout to that form? -Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444941 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 This is what I am unclear about if you go to http://mesquitechristmas.com/local/user.php?action=edit You will see the box, that will contain the user information etc. Now click on th edit this display and it will go to http://mesquitechristmas.com/local/user.php?action=edit&id= and it should bring up the form, but how do you bring up that form into that? The query is the easy part but how do I display the form on that same page when you click on "Edit This Display" -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444943 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 Well on http://mesquitechristmas.com/local/user.php?action=edit that page you need to set the id into the link i don't no whether your going to get that id out of a database or whatever, but u need to set the id before they click 'Edit This Display' so if its going to be <?php $user = $_SESSION['user']; $result = mysql_query("SELECT id FROM table WHERE user='$user'"); while($row = mysql_fetch_array($result)) { $id = $row['id']; echo "<a href='http://mesquitechristmas.com/local/user.php?action=edit&id=$id'>Edit This Display</a>"; } ?> i don't no if your sessions work like that, or if thats how u plan on doing that sort of thing, but that would be a way to do it i guess Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-444983 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Right I follow you about the ID needing to be in the link, that part I get. I wasn't sure how I was going to do my sessions exactly yet. I was going to do it by ID but I don't know if it would be easier to do it by email or ID. This user.php and everything in it will just show the information to that user that is logged in. I have the sessions.php page setup that I will call with an include statement. I might have to go back to redo it though. What I am not clear on though is how will that code above link to the update.php by using user.php?action=edit&id= to display that form? How does that work? currently this is how I was calling the ID into the link. <a href="user.php?action=edit&id=<?php echo $row['id'] ?>"><b>Edit This Display</b></a> Which way would be better? Ok I have been on this for 23hrs straight so I am going to get some sleep for now Thanks for your help, I really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-445011 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Anyone know how to I can link this page http://www.mesquitechristmas.com/local/update.php to this http://mesquitechristmas.com/local/user.php?action=edit&id= -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-445519 Share on other sites More sharing options...
Kingy Posted January 21, 2008 Share Posted January 21, 2008 ok well what u want is the following code in your switch case "edit" : include "update.php"; break; which now means that user.php?action=edit is now active and will work i understand u have a session for your email? that is easy enough as well to get the id then all you need to do is what i said previously except change the session to email <?php $email = $_SESSION['email']; $result = mysql_query("SELECT id FROM table WHERE email='$email'"); while($row = mysql_fetch_array($result)) { $id = $row['id']; echo "<a href='http://mesquitechristmas.com/local/user.php?action=edit&id=$id'>Edit This Display</a>"; } ?> that code should will display the link which will come out like http://mesquitechristmas.com/local/user.php?action=edit&id=# where # is equal to the userid. and then on the 'edit this display' page you need to have get the id out of the link using $_GET['id]; and do you sql querys Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-445606 Share on other sites More sharing options...
Dada78 Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks but if I change this case "edit": include "edit.php"; break; to this case "edit" : include "update.php"; break; Then it will no longer go to this page anymore. http://mesquitechristmas.com/local/user.php?action=edit When you click on Edit Entries at the top I need that page to show. Then when you click on "Edit This Display" in the box under the "Edit Entries" link at the top I need it to show this page. http://mesquitechristmas.com/local/update.php But the URL will only change to this. http://mesquitechristmas.com/local/user.php?action=edit&id=# I know the ID will have to be in their for the form to show the information it it. That I know how to do. I am just not sure how to link "Edit This Display" to show that form so the URL is shown as http://mesquitechristmas.com/local/user.php?action=edit&id=# Does that make sense or and I just not following what you are saying? -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-445631 Share on other sites More sharing options...
Kingy Posted January 22, 2008 Share Posted January 22, 2008 you can only have one case the same so it CAN'T be case "edit": include "edit.php"; break; case "edit": include "update.php"; break; it has to be different case "edit": include "edit.php"; break; case "update": include "update.php"; break; otherwise what you can do is something like... user.php?action=edit&sub=update which is easy enough EDIT.PHP <?php $sub = $_GET['sub']; if ($sub == update) { include "update.php"; // this will include everything you need to update etc etc } else { include "edit.php"; // this will include the links such as "edit this entry" } ?> i think by now, if you don't really understand what im trying to say i can't really do much else for ya, good luck... keep posting and i'll keep trying to help but ive explained the hole thing throughly now Quote Link to comment https://forums.phpfreaks.com/topic/86983-http_pos_vars/#findComment-445814 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.