Jump to content

Edit button


LearningKid

Recommended Posts

Hi so i have this code tht grabs some info from my db now there is an edit button now i want to kno if anyone can hlp me so tht when i click the eidt button it grabs the number of pages and take it to another page tht i have created.

looking forward to your kind hlp

<?php
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
echo "Hi $_SESSION[myusername] <br /><br />";

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="files"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql = "SELECT * FROM files where username = '".$_SESSION['myusername']."' ORDER BY id ASC ";
//$sql = "ORDER BY id ASC";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);

echo "<table border='2px'>\n";
echo " <tr>\n";
echo "  <td align='center'>Date Added</td>\n";
echo "  <td align='center'>Files</td>\n";
echo "  <td align='center'>Number of Pages</td>\n";
echo "  <td align='center'>Prepare To Print</td>\n";
echo "  <td> </td>\n";
echo " </tr>\n";

for ($i = 0; $i < $rows; $i++) {
  $data = mysql_fetch_object($result);
  // since our script is very small, i'm not going to escape out to html mode here
  echo " <tr>\n";
  echo "  <td>$data->Date</td>\n";
  echo "  <td>$data->File_Name</td>\n";
  echo "  <td align='center'>$data->Num_Pages</td>\n";
  echo "  <td align='center'><button>Edit</Button></td>\n";
  echo " </tr>\n";
}

?>
<html>
<body>
<a href="logout.php">leave</a>

</button>
</body>
</html>

Link to comment
Share on other sites

dpont use get its insecure. a;lways use post

 

POST is just as insecure. You use whichever one is needed. For searches you want to use GET so they can be linked / bookmarked. Where as submitting forms with a bunch of data you want to use POST due to the size limitations of GET. But either method is "insecure" if you do not filter the data.

Link to comment
Share on other sites

lol i got the action post thingy, and thank you all one last thing i tried playin around but how do i get the info on the other page?

i tried something like

<?php
if ($_POST['infoineed']) {echo $_POST['infoineed'] };
?>

but tht obviosly doesnt work lol so im lookin online to figure it out if u guys have any hlp please assist.

Thank YOu

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.