LearningKid Posted December 18, 2009 Share Posted December 18, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/ Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 <form><input type="submit" value="edit" name="editbutton"> </form> <?php if(isset($_POST[editbutton[)){do the thing here hon} ?> Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980125 Share on other sites More sharing options...
LearningKid Posted December 18, 2009 Author Share Posted December 18, 2009 thank you ill try it now Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980128 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 make sure to do form action="post" method="theurul"> Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980130 Share on other sites More sharing options...
mikesta707 Posted December 18, 2009 Share Posted December 18, 2009 look into GET/POST. You want to send a unique identifier (like the primary key. usually set to auto increment) via get/post to the page you create, and use the unique ID to get the row you want to edit from the table Basically what emo said, but you need to send some information to the page Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980132 Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 dpont use get its insecure. a;lways use post Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980137 Share on other sites More sharing options...
premiso Posted December 18, 2009 Share Posted December 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980152 Share on other sites More sharing options...
oni-kun Posted December 18, 2009 Share Posted December 18, 2009 make sure to do form action="post" method="theurul"> Wait, It's action="url" method="post" .. lol Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980156 Share on other sites More sharing options...
LearningKid Posted December 18, 2009 Author Share Posted December 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/185622-edit-button/#findComment-980186 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.