Jump to content

help needed


abeer

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/239215-help-needed/
Share on other sites

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>

 

 

Link to comment
https://forums.phpfreaks.com/topic/239215-help-needed/#findComment-1229010
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.