abeer Posted June 13, 2011 Share Posted June 13, 2011 I have a script which display id contet from mysql database by grabing the url value here is the script: <?php mysql_connect("localhost", "dhaka", "dhaka") or die("Connection Failed");mysql_select_db("dhaka")or die("Connection Failed");// Sanitize the page ID$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_VALIDATE_INT) : NULL;if (is_int($id)) { $result = mysql_query("SELECT * FROM page WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_array($result); echo 'content: ' . $row['dtl'];} else { die('Possible hack attemp!');}?> it works fine.. but i have another script to edit mysql rows by text area . but i want to make it like above script which will change the id automatic by grabinng the url value <?php mysql_connect("mysql1", "splash", "splash") or die("Connection Failed"); mysql_select_db("splash")or die("Connection Failed"); if(isset($_POST['id'])) { echo $sql="UPDATE page SET dtl='".$_POST['content']."' WHERE id = ".$_POST['id']; mysql_query($sql) or die(mysql_error()); } $result = mysql_query("SELECT * from page WHERE id = 3"); $data = mysql_fetch_assoc($result); $id = $data['id']; $content = $data['dtl']; ?> <html> <head></head> <body> <form name="change_content" method="POST" action="editnow.php"> <input type="hidden" name="id" value="<?php echo $id; ?>"> <textarea name="content"><?php echo $content; ?></textarea> <input type="submit" value="change"> </form> </body> </html> 1. please help me in where ihave to make change to do this? 2. look the script in action http://www.platformsociety.org/ck.php whwn i click the change button it echos all the enterd data with row number above the text area and the text area appear without ck editor i am very new in php. please help me. Advance thanks and salute for you all Quote Link to comment https://forums.phpfreaks.com/topic/239215-help-needed/ Share on other sites More sharing options...
RussellReal Posted June 13, 2011 Share Posted June 13, 2011 change $_POST to $_GET, $_POST is for post form data, and $_GET is for url variables. Quote Link to comment https://forums.phpfreaks.com/topic/239215-help-needed/#findComment-1228995 Share on other sites More sharing options...
abeer Posted June 13, 2011 Author Share Posted June 13, 2011 Friend... here is the modified codes is it ok now? <?php mysql_connect("mysql1", "splash", "splash") or die("Connection Failed"); mysql_select_db("splash")or die("Connection Failed"); if(isset($_GET['id'])) {echo $sql="UPDATE page SET dtl='".$_POST['content']."' WHERE id = ".$_POST['id'];mysql_query($sql) or die(mysql_error());}$result = mysql_query("SELECT * from page WHERE id = 3");$data = mysql_fetch_assoc($result);$id = $data['id'];$content = $data['dtl'];?><html><head></head><body><form name="change_content" method="POST" action="editnow.php"><input type="hidden" name="id" value="<?php echo $id; ?>"><textarea name="content"><?php echo $content; ?></textarea><input type="submit" value="change"></form></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/239215-help-needed/#findComment-1229010 Share on other sites More sharing options...
runnerjp Posted June 13, 2011 Share Posted June 13, 2011 Where are you string ur id? Quote Link to comment https://forums.phpfreaks.com/topic/239215-help-needed/#findComment-1229023 Share on other sites More sharing options...
abeer Posted June 13, 2011 Author Share Posted June 13, 2011 i am really new in php. please correction me where is the problem Quote Link to comment https://forums.phpfreaks.com/topic/239215-help-needed/#findComment-1229058 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.