i m newbie in web development plz help me to sort out the problem..
the problem is: in edit.php when control enters in if condition it never goes to else when i press the edit button.

i want to get id from view.php and display category name in edit.php textbox so i can change the category name by pressing edit button.

view.php

<?
		require("Datab.class.php");
		$db = new Datab("localhost", "root", "intaha", "subc");
		$db->connect();
	
		$result = $db->query("select * from category");
		
		?>
		<table border="1" cellpadding="0">
        <? 

		if(mysql_num_rows($result)){
			
			while($rows = mysql_fetch_row($result)){ ?>
                <tr>
                <td><? echo $rows[0]; ?></td> 
                <td><? echo $rows[1]; ?></td>
                <td><a href="edit.php?id=<?=$rows[0]?>">edit</a></td>                
                <td><a href="delete.php?id=<?=$rows[0]?>">delete</a></td>
          
                           
				</tr>
            <?	
			}
		}
		?> </table>

edit.php

<html>
<head>
<title></title>
</head>
<body>


<?php
		require("Datab.class.php");
		$db = new Datab("localhost", "root", "intaha", "subc");
		$db->connect();
		$id = $_GET['id'];
		echo "hello this is upper.... $id";			
		
		$result = $db->query("select name from category where category_id = $id");
		
		$name = "";
		if(mysql_num_rows($result) > 0){
			while($rows = mysql_fetch_row($result)){
				$name = $rows[0];
			}
		}
		
	if(!isset($_POST['submit'])){
		echo "<br> in !isset condition..... <br> ";
		?>	
			<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
			<input type="text" name="cat_name"  value= "<? echo $name; ?>" />
			<input type="submit" name="submit" value="edit" />
			</form>
		<?
	}else{
		echo "<br> in else condition..... <br> ";
		$uname= $_POST['cat_name'];
		echo "name = " .$uname;
		echo "in id = " . $id . "  ";
		$result = $db->query("update category SET name = '$uname' where category_id = $id");
		echo "Category name changed ";
	}
		?>
        

</body>
</html>

You are not posting the values from view.php, you are just sending through query string.

so in edit.php you need to take the data something like $_REQUEST

You are not submitting the data in a form (So why are you checking in if condition as $_POST)

I suggest you to send one more parameter kin view.php, such as

<a href="edit.php?id=<?=$rows[0]?>&action=edit">edit</a>

<a href="delete.php?id=<?=$rows[0]?>&action=delete">delete</a>

and in edit.php
check for $_REQUEST == 'edit'

It is as saiprem wrote,
the semantics of php do not consider, as people do in spoken language, that post get request are 'similar enough' to be interchangeable
$_post does not show the data sent in the query string, and is harder to fake
if the data being edited is subject to attack,
privacy issues,
security needs,
it is definitely better to $_post the data from one page to another,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.