<br/> <b>注意</b>:未定义的变量:<b> C:\ xampp \ htdocs \ form2 \ edit.php </b>中的用户名<b> 7 </b> </b >

时间:2016-04-22 08:09:39

标签: php

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


通知 7 C:\ xampp \ htdocs \ form2 \ edit.php 中未定义的变量:user_name

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


注意:未定义的变量: C:\ xampp \ htdocs \ form2 \ edit.php 中的地址 9
  提交

我创建了一个edit.php并更新了值

我正在运行PHP脚本,并且维护错误,如:

1 个答案:

答案 0 :(得分:0)

如果您使用的是某个变量,请检查其是否设置

<?=$user_name;?> you need to chnage to <?=(isset($user_name)?$user_name:""?> and same for others.