Jump to content

[SOLVED] page ID's for live edit??


DeanWhitehouse

Recommended Posts

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();

 

 

Link to comment
Share on other sites

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.

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.