I am trying to make a editable website, so I was making the textarea to edit the database …
But its not working :’( heres the script :’(
<html><head></head><body>
<form action="Editnote.php" method="post">
<textarea name="newdata" rows="10" WRAP=HARD cols="50" width="95" height="300px" style="width:95%;height:300px">
<?php
//NEW
$con = mysql_connect("localhost",YYY","ZZZ");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("32711", $con);
$result = mysql_query("SELECT * FROM Robin105editor");
while($row = mysql_fetch_array($result))
{
echo $row['Notepad'];
}
mysql_close($con);
?>
</textarea>
<br>
<textarea name="olddata" rows="10" cols="10" >
<?php
//NEW
$con = mysql_connect("localhost","YYY","ZZZ");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("32711", $con);
$result = mysql_query("SELECT * FROM Robin105editor");
while($row = mysql_fetch_array($result))
{
echo $row['Notepad'];
}
mysql_close($con);
?>
</textarea>
<input type="submit">
</form>
</body></html>
Heres Editnote.php
<html><head></head><body>
<?php
$old = $_POST['olddata'];
$new = $_POST['newdata'];
$con = mysql_connect("localhost","YYY","ZZZ");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("32711", $con);
mysql_query("UPDATE `Robin105editor` SET `Notepad`='$new' WHERE `Notepad`='$old'");
mysql_close($con);
?>
</body></html>