2
Contributors
14
Replies
15
Views
8 Years
Discussion Span
Last Post by furqan219
0

Hi all I need Help.
$b is a variable vaue which I have populated from the databse and showing in field.
but when I use POST method its not working.

In Form.php

<form action="update.php" method="post">
<input type="text" name="siteid" value="<?= $b ?>" />
<input type="submit" name="subjoin" value="Update">
</form>

in update page how I show the value of site id. I am using post method. but field value is variable($b) so how I can I post the value to next page?
In update.php

$c = $_post["$b"]; 
echo $c; //its not working.

Thanks in advance

0

hello

you can get this value like this in update.php file

$c=$_post['siteid'];
echo "value".$c;

I hope your problem may be solve

Thanks.

0
$c= $_POST['siteid']
echo "value".$c

gives this error

Parse error: parse error in C:\xampp\htdocs\update.php on line 24

0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
$con = mysql_connect("localhost","****","****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("onm", $con);

$result = mysql_query("SELECT * FROM sitepinfo
WHERE SiteId='C-SIL-4441' "); // I just get one value at this time


while($row = mysql_fetch_array($result))
  {
  echo "<table cellpadding=2 cellspacing=2 width=100%>
<tr>


</tr>";
  echo "<tr>";
  echo "<th bgcolor=#5D9BCC >SiteID</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['SiteId'] . "</td>"; // show value in cell

 
 $b =$row['SiteId']; // store value in $b
 


  
 
  

  echo "</tr>";
 
  }
echo "</table>";


mysql_close($con);

?>
<form action="update.php" method="post">

<input type="text" name="userdate" value="<?= $b ?>" /> 

<input type="submit" name="subjoin" value="Update">

</form>

</body>
</html>

and update.php page is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Record</title>
</head>

<body>



<?php




$con = mysql_connect("localhost","XXXXX","XXXXXXX");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 $c= $_POST['siteid']
echo "value".$c
print $c; //ITS NOT WORKING
mysql_select_db("onm", $con);

/*mysql_query("UPDATE SitePInfo SET Age = '36'
WHERE FirstName = 'Peter' AND LastName = 'Griffin'");
*/
mysql_close($con); 
?> 
</body>
</html>
0

$c= $_POST
echo "value".$c
gives this error

Parse error: parse error in C:\xampp\htdocs\update.php on line 24

hi
you have no pu ';' semicolon after the
this code

$c= $_POST['siteid'];
echo "value".$c;

parse error means you miss ; in script ok.

0

hi
this is your code but you can also do easy way in php
so i just ediit it like

<?php
while($row = mysql_fetch_array($result))
{ ?>
<table cellpadding=2 cellspacing=2 width=100%>
<tr>
</tr>
<tr>
<th bgcolor=#5D9BCC >SiteID</th>
<td bgcolor=#FEE9A9><?= $row['SiteId'] ?>/td>
</tr>
</table>
<?
$b =$row['SiteId']; // store value in $b
}

this code is not generate complexity.......
you save your time of solving your parse error right

Thanks

0

now its shwoing in result value

I am confused please give me updation example.
Ihave attache pic.

Attachments update.jpg 82.66 KB
0

hi

if you want to fetch only one row so that time no need of while loop ok

$row=mysql_fetch_array($result);

this is enough code.
now first of all you need to put name address and city value in text box ok

<form action="update.php" method="post">
<table>
<tr>
<td>name</td>
<td>
<input type="text" name="username" id="username" value="<?=$row['name'] ?>" /> </td></tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="address" id="address" value="<?=$row['address']?>"></td></tr>
<tr>
<td>city</td>
<td>
<input type="text" id="city" name="city" value="<?=$row['city']?>">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Update"/>
</td>
</tr>
<input type="hidden" value="<?=$row["siteid"]?>" name="siteid" nmae="siteid">
</table>
</form>

now this in update.php file

$name=$_post["username"];
$address=$_post["address"];
$city==$_post["city"];
$id=$_post['siteid'];
$query="update table_name set name='$name',address='$address',city='$city' where siteid='$id'"'
mysql_query($query);

i posted complete code for update profile now you need to change design and table fields as per your requirment

Thanks

0

please check this hidden field is not showing any value now. and not working. how i change while loop to just statement. when i delete it gives error so please make this correct.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
$con = mysql_connect("localhost","xxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("new", $con);

$result = mysql_query("SELECT * FROM abc
WHERE SiteId='C-SIL-4441' "); // I just get one value at this time


while($row = mysql_fetch_array($result))
  {
  echo "<table cellpadding=2 cellspacing=2 width=100%>
<tr>


</tr>";
  echo "<tr>";
  echo "<th bgcolor=#5D9BCC >SiteID</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['SiteId'] . "</td>"; // show value in cell

 
 $b =$row['SiteId']; // store value in $b
 


  
 
  

  echo "</tr>";
 
  }
echo "</table>";


mysql_close($con);

?>
<form action="update_tulsa.php" method="post">
<table>
<tr>
<td>name</td>
<td>
<input type="text" name="username" id="username" value="<?=$row['name'] ?>" /> </td></tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="address" id="address" value="<?=$row['address']?>"></td></tr>
<tr>
<td>city</td>
<td>
<input type="text" id="city" name="city" value="<?=$row['city']?>">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Update"/>
</td>
</tr>
<input type="hidden" value="<?=$row["siteid"]?>" name="siteid">
</table>

</body>
</html>

and update.php page is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update Record</title>
</head>

<body>



<?php




$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


mysql_select_db("new", $con);

$name=$_post["username"];
$address=$_post["address"];
$city==$_post["city"];
$id=$_post['siteid'];

$query=mysql_query("update table_name set name='$name',address='$address',city='$city' where siteid='$id'");



mysql_close($con); 
?> 
</body>
</html>
0

I also change table name with abc that was my mistake but its not posting values to update_tulsa.php

0

hi
after seen your code i notice that you have not complete form tag
after the table of first page right.
so now your are not able to view any posted fields ok

Thanks

0

Now its working.
Can I ask another Question?
But please remove the while loop and also tell me how I can get value from result in a varaible from report.php to form.php

thank you so much............
form.php here

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("new", $con);

$result = mysql_query("SELECT * FROM abc
WHERE SiteId='C-SIL-4441' "); // I just get one value at this time


while($row = mysql_fetch_array($result))
  {
  echo "<table cellpadding=2 cellspacing=2 width=100%>
<tr>


</tr>";
  echo "<tr>";
  echo "<th bgcolor=#5D9BCC >SiteID</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['SiteId'] . "</td>";
  echo "<td bgcolor=#FEE9A9>" . $row['Name'] . "</td>";
  echo "<td bgcolor=#FEE9A9>" . $row['Address'] . "</td>";
  echo "<td bgcolor=#FEE9A9>" . $row['City'] . "</td>"; // show value in cell

 
 $b =$row['SiteId']; 
  $c =$row['Name'];
   $d =$row['Address'];
    $e =$row['City'];// store value in $b
 



  
 
  

  echo "</tr>";
 
  }
echo "</table>";


mysql_close($con);

?>
<form action="update2.php" method="post">
<table>
<tr>
<td>name</td>
<td>
<input type="text" name="username" id="username" value="<?php echo $c; ?>" /> </td></tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="address" id="address" value="<?php echo $d; ?>"></td></tr>
<tr>
<td>city</td>
<td>
<input type="text" id="city" name="city" value="<?php echo $e; ?>">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Update"/>
</td>
</tr>
<input type="text" value="<?php echo $b; ?>" name="siteid">
</table>

</body>
</html>
<body>



<?php




$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


mysql_select_db("new", $con);

if(!empty($_POST["siteid"]))
{
$a= $_POST["siteid"];
echo $a; //its working
}

if(!empty($_POST["username"]))
{
$c= $_POST["username"];
echo $c; //its working
}

if(!empty($_POST["address"]))
{
$d= $_POST["address"];
echo $d; //its working
}

if(!empty($_POST["city"]))
{
$e= $_POST["city"];
echo $e; //its working
}



$query=mysql_query("update abc set name='$c',address='$d',city='$e' where siteid='$a'");



mysql_close($con); 
?> 
</body>
</html>
0

hi

i just edit form.php file here
and findout that how it works

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("new", $con);

$result = mysql_query("SELECT * FROM abc
WHERE SiteId='C-SIL-4441' "); // I just get one value at this time


$row = mysql_fetch_array($result);
?>
  <table cellpadding=2 cellspacing=2 width=100%>
<tr>
</tr>
<tr><th bgcolor=#5D9BCC >SiteID</th>
<td bgcolor=#FEE9A9><?= $row['SiteId']?></td>
<td bgcolor=#FEE9A9><?= $row['Name']?></td>
<td bgcolor=#FEE9A9><? $row['Address']?></td>
<td bgcolor=#FEE9A9><?= $row['City'] ?></td>
</tr>
</table>
 
<? $b =$row['SiteId']; 
   $c =$row['Name'];
   $d =$row['Address'];
   $e =$row['City'];// store value in $b
mysql_close($con);
?>

hope you understand above code ok
if your problem solved then you need to mark as solved thread ok

Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.