0

I am sending a parameter through URL like: domain-name.com/Edit-user.php?reg_no=NV000003 and retrieving data into in textfields for reg_no NV000003 from database. It is fine here but when I click on modify button and submit form by using below code:

<?php
if(/$_POST){
$query=mysql_query("update table-name set 
    NAME = '".(/$_REQUEST['name'])."',
    EMAIL = '".(/$_REQUEST['email'])."'
    where field-name = 'particular-value'
    ");
    ?>

It is updating the data table but with empty values in all fields. May be I am missing somthing. Any idea Plsss?

my form is

   <form action="" method="post" id="modifystndt" name="modifystndt"> 
   <table> <tbody> <tr> <td width="200px">Name of Student:</td> 
   <td width="400px"><strong><input type="text" name="name" id="name" value="<?php echo $NAME; ?>"></strong></td> </tr>
   <tr> <td>E-mail :</td> <td><strong><input type="text" name="name" id="name" value="<?php echo $EMAIL; ?>"></strong></td> </tr> 
   <tr> <tbody> <table> </form>
4

2 回答 2

0

尝试这个

     $query=mysql_query("update table-name set 
NAME = '".$_REQUEST['name']."',
EMAIL = '".$_REQUEST['email']."'
where `field-name` = 'particular-value'
");

正如我在您的表格中看到的,有很多错误。

  • 你不关闭表,tbody,tr,输入标签。

  • NAME您对 和 的两个输入使用了相同的名称和相同的 ID email

将电子邮件的输入更改为

    <input type="text" name="email" id="email" value="<?php echo $EMAIL; ?>" />

编辑2:

尝试这个

 <?php
  if(isset($_POST['modifystndt'])){
 $query=mysql_query("update table-name set 
 NAME = '".$_POST['name']."',
 EMAIL = '".$_POST['email']."'
 where field-name = 'particular-value'
 ");
 ?>

你的表格:

   <form action="" method="post" id="modifystndt" name="modifystndt"> 
 <table> <tbody> <tr> <td width="200px">Name of Student:</td> 
 <td width="400px"><strong><input type="text" name="name" id="name" value="<?php echo $NAME; ?>" /></strong></td> </tr>
 <tr> <td>E-mail :</td> <td><strong><input type="text" name="email" id="email" value="<?php echo $EMAIL; ?>" /></strong></td> </tr> 
</tbody> </table> 
  <input type="submit" name="submit" value="Submit"/></form>
于 2013-08-01T10:37:47.140 回答
0

如果您的表单方法是 POST,您可以使用数组 $_POST 检索数据。

$query=mysql_query("update table-name set 
   NAME = '".$_POST['name']."',
   EMAIL = '".$_POST['email']."'
   where `field-name` = 'particular-value'
");
于 2013-08-01T11:36:47.630 回答