Jump to content

Recommended Posts


I'm trying to code a form which will allow users to update a page on my site for them to quick view from their user panel instead of having to search for the page again.

 

I have a user system. I'm trying this code at the moment with limited success..

 

I currently use this link on pages i want bookmarking:

 

<a href="bookmark.php?page=<?php echo urlencode("http://codeapple.com" . $_SERVER["REQUEST_URI"]); ?>">Bookmark this page</a> 

 

Which takes users to this page:

 

bookmark.php

 

<?
//***************************************
// This is downloaded from www.plus2net.com //
/// You can distribute this code with the link to www.plus2net.com ///
//  Please don't  remove the link to www.plus2net.com ///
// This is for your learning only not for commercial use. ///////
//The author is not responsible for any type of loss or problem or damage on using this script.//
/// You can use it at your own risk. /////
//*****************************************
include "include/session.php";
include "include/z_db.php";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>(Type a title for your page here)</title>

<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">




<?

echo "
<center>
<font face='Verdana' size='2' >
Hello, <b>$session[userid]</b></center>
<hr>


</font>";
if(isset($_GET['page'])){
echo "<form action=bookmark.php method=post>
<input type=hidden name=page value=$_GET

 />
Set bookmark <b>$session[userid]</b>
<select name=bookmark_number>
  <option value=1>1</option>
  <option value=2>2</option>
  <option value=3>3</option>
  <option value=4>4</option>
  <option value=5>5</option>
  <option value=6>6</option>
</select>
to $_GET

<input type=submit value=Set>
</form>";

}elseif(isset($_POST['bookmark_number'])){
$query="UPDATE `plus_signup` SET `book".$_POST['bookmark_number']."` = '".$_POST['page']."' WHERE `userid` = '".$SESSION['userid']."';";
mysql_query($query);
header('Location: welcome.php');
}else{
header('Location: welcome.php');
}

?>


</body>

</html>

 

 

The trouble i'm having is that i want to set a maximum amount of bookmarks per user, say 10 or 20. Currently, users can bookmark any page with the link on. It would have to do something like check if cell bookmark1 was empty in the DB, if yes, then add the link of the bookmark to that cell for that user. If its not empty, then it moves to cell bookmark2 etc. Until the allocated 10 or 20 cells are filled, then users have to overwrite one if they want a new bookmark.

 

Does anyone know how to help?

Link to comment
https://forums.phpfreaks.com/topic/90789-update-form-bookmark-pages/
Share on other sites

Nevermind, i got this script working perfectly with this bookmark.php:

 

<?
//***************************************
// This is downloaded from www.plus2net.com //
/// You can distribute this code with the link to www.plus2net.com ///
//  Please don't  remove the link to www.plus2net.com ///
// This is for your learning only not for commercial use. ///////
//The author is not responsible for any type of loss or problem or damage on using this script.//
/// You can use it at your own risk. /////
//*****************************************
include "include/session.php";
include "include/z_db.php";
?>

<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>(Type a title for your page here)</title>

<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<?

echo "
<center>
<font face='Verdana' size='2' >
Hello, <b>$session[userid]</b></center>
<hr>


</font>";


if(isset($_GET['page'])){
//print form
echo '<form action="bookmark.php" method="post">
<input type="hidden" name="page" value="'.$_GET['page'].'" />
Set bookmark 
<select name="bookmark_number">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
</select>
to '.$_GET['page'].'
<input type="submit" value="Set">
</form>';
}elseif(isset($_POST['bookmark_number'])){
$query="UPDATE `plus_signup` SET `book".$_POST['bookmark_number']."` = '".$_POST['page']."' WHERE `userid` = '".$session['userid']."';";
mysql_query($query);
header('Location: welcome.php');
}else{
header('Location: welcome.php');
}

?>

</body>

</html>

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.