DeanWhitehouse Posted May 10, 2008 Share Posted May 10, 2008 i am using sessions on each page, the session is set to a varaible with the page name in it , how can i make it so that if you visit the page editor it gives you a choice of pages to edit, but if you go there through a page link it is on the correct editing part. That probably didn't make sense , so here is my code this is on each page $pagename = "index.php"; // different value on each page $_SESSION['page_name'] = $pagename; and then there is a link <td><a href="live_edit.php?edit=<?php echo $_SESSION['page_name'] ?>">Edit</a></td></tr></table> for each page for direct editing, and here is my editing page if ($_SESSION['logged_in'] == true) { $page_id = $_SESSION['page_name']; $sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $welcome = $row['content']; ?> <p>Editing <?php echo "$page_id"; ?></p> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit" value="Change" title="Save Changes"/></form> <?php } else { header("Location:http://".$_SERVER[HTTP_HOST]); } mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/ Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Use $_GET.... Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/#findComment-537241 Share on other sites More sharing options...
peranha Posted May 10, 2008 Share Posted May 10, 2008 pageid = $_GET['edit']; yeah, fixed it, didnt realize that. Working on too many things at once I guess Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/#findComment-537244 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Except for the fact that you closed the array index with a '}', yeah. Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/#findComment-537246 Share on other sites More sharing options...
DeanWhitehouse Posted May 10, 2008 Author Share Posted May 10, 2008 ok, i am now using this , if ($_SESSION['logged_in'] == true) { if (isset($_GET['edit'])) { if ((int) $_GET['edit'] > 0) { $userid = $_GET['edit']; $sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $welcome = $row['content']; ?> <p>Editing <?php echo "$page_id"; ?></p> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit" value="Change" title="Save Changes"/></form> <?php if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } exit(); } else { echo "Unknown User ID! <br />"; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT page_name, content FROM hayleyedit"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { echo "User List:<br />"; while ($row = mysql_fetch_assoc($result)) { echo '<table border="1"><tr><td><a href="?id=' . $row['page_name'] . '">' . $row['content'] . '</a></td></tr></table>'; } } } else { header("Location:http://".$_SERVER[HTTP_HOST]); } what can i replace these with > 0 as i am using page names like, index.php not 1, 2 etc. Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/#findComment-537248 Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 if ($_SESSION['logged_in'] == true) { if (isset($_GET['edit']) && strlen($_GET['edit']) > 0) { //stuff here } //more session stuff if necessary } Quote Link to comment https://forums.phpfreaks.com/topic/104955-solved-page-ids-for-live-edit/#findComment-537250 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.