-2
<!doctype html>
<html>
<head>
<title></title></head>
<body>
<form action="#" method="POST" enctype="multipart/form-data">
<input type="text" name="usname" value = "<?=$user_name;?>"/>
<input type="password" name="psd" value = "<?=$pass_word;?>" />
<input type="textarea" name="addrs" value = "<?=$address;?>">
<input type="hidden" name="id" value = "<?=$id?>"/>
<input type="submit" name="submit" value="submit"/>
</form>
<?php
if(isset($_POST['submit'])){

    $sql= "Update form set user_name='".$_POST['usname']."',
                         pass_word='".$_POST['psd']."',
                         address='".$_POST['addrs']."'
 where id='".$_GET['id']."'
 ";

 $result=mysql_query($sql);
if($result)
{
    echo"data is succesfully data insert";
header("location:login.php");
}else
{echo"";}
}
$id='';
$user_name='';
$pass_word='';
$address='';
$host="localhost";
$username="root";
$password="";
$db="form2";
$con=mysql_connect($host,$username,$password);

if(isset($_GET['id']))
{
 echo $query = "select id,user_name,pass_word,address from form where id=".$_GET['id'];
mysql_select_db($db,$con);

 echo $result=mysql_query($query);
if($result){
    while($row= mysql_fetch_array($result))
     $id=$row['id'];
     $user_name=$row['user_name'];
     $pass_word=$row['pass_word'];
    $address=$row['address'];

    }
}
?>

</body>
</html>


Notice: Undefined variable: user_name in C:\xampp\htdocs\form2\edit.php on line 7

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••


Notice: Undefined variable: address in C:\xampp\htdocs\form2\edit.php on line 9
submit

i am create a edit.php and update the values

I'm running a PHP script, and maintain getting errors like:

rakesh suryan
  • 1
  • 1
  • 1
  • 1

1 Answers1

1

If you are using some variable then please check if its set or not

<?=$user_name;?> you need to chnage to <?=(isset($user_name)?$user_name:""?> and same for others. 
Brijal Savaliya
  • 1,101
  • 9
  • 19