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