简体   繁体   中英

php_self issue form submit

please if you could help me with this, i have a problem with the php_self coding, this is my code: This is the php code

<?php
if (isset($_POST['submit']))
{
$id=$_REQUEST['id'];
$notes_en=$_REQUEST['notes_en'];

$notes_ru=$_REQUEST['notes_ru'];


$sql="UPDATE hostess SET notes_en='$notes_en',notes_ru='$notes_ru' WHERE id='$id'";
$result=mysql_query($sql);
if($result){
echo "<div id='edittxt'>successfully updated";
echo "<BR>";
echo '<td ><a href="index.php">View Results</a></div>';
}

else {
die('error'.mysql_error());
}}


?>

This here is the form code from which i ake the information 
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label>Notes</label></br><div id="note"><h1><textarea value="<?php echo $star['notes_en'];?>"><?php echo $star['notes_en'];?></textarea></h1></div></br>

<input name="id" type="hidden" id="id" value="<?php echo $star['id'];?>">

<input type="submit" value="submit" name="submit"></form>"

If possible please check it because i've been trying to modify it and i get no results, it doesn't give me errors but neither does it update the database

You don't have a name attribute on your field. Also, doesn't takes a value attribute.

Try this:

<textarea name="notes_en"><?php echo $star['notes_en'];?></textarea>

Furthermore, I definitely recommend following Marc B's advice and protecting yourself against SQL injection attacks. Have a look at this thread:

How can I prevent SQL injection in PHP?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM