niths
05-24-2010, 12:57 PM
hi all,
i am a new bee.i had a problem. I had a text box and i need that value after isset so before isset if echo then i am getting that value but after this isset i am not getting it.so can any one. u can understand after seeing my code.
<html>
<body>
<?php
$id=$_GET['f1'];
include 'connection.php';
$query="select * from users where userid='$id'";
mysql_error();
$result = mysql_query ($query) ;
$num=mysql_num_rows($result);
$i=0;
While($i < $num)
{
$userid=mysql_result($result,$i,"userid");
$sqlusername=mysql_result($result,$i,"username");
$password=mysql_result($result,$i,'password');
$role=mysql_result($result,$i,"role");
$status=mysql_result($result,$i,'status');
//$reportingto=mysql_result($result,$i,'reportingto');
$allocatedmemory=mysql_result($result,$i,"allocatedmemory");
$arr_id=split("[{ }-]" ,$allocatedmemory);
$i++;
}
?>
<form action="update.php" method="post">
<div>
<center>
<table>
<tr>
<td style="color: navy;">Userid</td>
<td><input type="text" readonly="readonly" name="userid" value="<? echo $userid; ?>"></td>
</tr>
<tr>
<td style="color: navy;">Username</td>
<td><input type="text" name="username" id="txtname" value="<? echo $sqlusername; ?>"></td>
</tr>
<tr>
<td style="color: navy;">Password</td>
<td><input type="password" name="password" id="pwd" value="<? echo $password; ?>"></td>
</tr><tr>
<td style="color: navy;">Status:</td>
<td><select name="status">
<?php
if($status == 1)
{
echo '<option value="Active" selected="selected">Active</option>';
echo '<option value="Inactive">Inactive</option>';
}
else
{
echo '<option value="Inactive" selected="selected">Inactive</option>';
echo '<option value="Active">Active</option>';
}
?>
</select></td></tr>
<tr>
<td style="color: navy;">Allocatedmemory</td>
<td><input type="text" onkeypress="return isNumberKey(event)" id="am" name="allocatedmemory" value="<? echo $arr_id[0]; ?>"></td>
<td><select name="size">
<?php
if($arr_id[1]== "KB")
{
echo '<option value="MB">MB</option>';
echo '<option value="KB" selected="selected">KB</option>';
}
else
{
echo '<option value="MB" selected="selected">MB</option>';
echo '<option value="KB">KB</option>';
}?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btn" value="Update" onclick="return (confirm('Are you sure you want to Update this?'),check())"/>
<input type="submit" name="btn" value="Delete" onclick="return (confirm('Are you sure you want to delete this?'))"/></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
<?php
$user=$sqlusername;
echo $user;
if(isset($_POST['btn']))
{
include 'connection.php';
if($_POST[btn]== 'Update')
{
$pname=$_POST['username'];
if($_POST[status] == 'Active')
$_POST[status] = 1;
else{
$_POST[status] = 0;
}
echo $pname;
if($user==$pname)
{
mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
echo "<script language='javascript'>
alert('User details updated');
</script>";
echo "<script language='javascript' type='text/javascript'>
window.close();
</script>";
}
else{
$query="select * from users where username='$pname'";
mysql_error();
$result=mysql_query($query);
$count=mysql_num_rows($result);
if($count==0)
{
mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
}
else
{
echo "<script language='javascript'>
alert('Username already exists');
</script>";
}
}
}
else if($_POST[btn] == 'Delete')
{
mysql_query("Delete from users where userid ='$_POST[userid]'");
echo "<script language='javascript'>
alert('Data Deleted');
</script>";
echo "<script language='javascript' type='text/javascript'>
window.close();
</script>";
}
}
?>
This is a big code as it is difficult to see all this,i can make it small for u to make clear my problem.so see the line no.14,34,85,86,92,99.
so wat i need to get is the value of line 86 after line 87. so that my condition in line no.99 can work
Thank u.
i am a new bee.i had a problem. I had a text box and i need that value after isset so before isset if echo then i am getting that value but after this isset i am not getting it.so can any one. u can understand after seeing my code.
<html>
<body>
<?php
$id=$_GET['f1'];
include 'connection.php';
$query="select * from users where userid='$id'";
mysql_error();
$result = mysql_query ($query) ;
$num=mysql_num_rows($result);
$i=0;
While($i < $num)
{
$userid=mysql_result($result,$i,"userid");
$sqlusername=mysql_result($result,$i,"username");
$password=mysql_result($result,$i,'password');
$role=mysql_result($result,$i,"role");
$status=mysql_result($result,$i,'status');
//$reportingto=mysql_result($result,$i,'reportingto');
$allocatedmemory=mysql_result($result,$i,"allocatedmemory");
$arr_id=split("[{ }-]" ,$allocatedmemory);
$i++;
}
?>
<form action="update.php" method="post">
<div>
<center>
<table>
<tr>
<td style="color: navy;">Userid</td>
<td><input type="text" readonly="readonly" name="userid" value="<? echo $userid; ?>"></td>
</tr>
<tr>
<td style="color: navy;">Username</td>
<td><input type="text" name="username" id="txtname" value="<? echo $sqlusername; ?>"></td>
</tr>
<tr>
<td style="color: navy;">Password</td>
<td><input type="password" name="password" id="pwd" value="<? echo $password; ?>"></td>
</tr><tr>
<td style="color: navy;">Status:</td>
<td><select name="status">
<?php
if($status == 1)
{
echo '<option value="Active" selected="selected">Active</option>';
echo '<option value="Inactive">Inactive</option>';
}
else
{
echo '<option value="Inactive" selected="selected">Inactive</option>';
echo '<option value="Active">Active</option>';
}
?>
</select></td></tr>
<tr>
<td style="color: navy;">Allocatedmemory</td>
<td><input type="text" onkeypress="return isNumberKey(event)" id="am" name="allocatedmemory" value="<? echo $arr_id[0]; ?>"></td>
<td><select name="size">
<?php
if($arr_id[1]== "KB")
{
echo '<option value="MB">MB</option>';
echo '<option value="KB" selected="selected">KB</option>';
}
else
{
echo '<option value="MB" selected="selected">MB</option>';
echo '<option value="KB">KB</option>';
}?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btn" value="Update" onclick="return (confirm('Are you sure you want to Update this?'),check())"/>
<input type="submit" name="btn" value="Delete" onclick="return (confirm('Are you sure you want to delete this?'))"/></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
<?php
$user=$sqlusername;
echo $user;
if(isset($_POST['btn']))
{
include 'connection.php';
if($_POST[btn]== 'Update')
{
$pname=$_POST['username'];
if($_POST[status] == 'Active')
$_POST[status] = 1;
else{
$_POST[status] = 0;
}
echo $pname;
if($user==$pname)
{
mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
echo "<script language='javascript'>
alert('User details updated');
</script>";
echo "<script language='javascript' type='text/javascript'>
window.close();
</script>";
}
else{
$query="select * from users where username='$pname'";
mysql_error();
$result=mysql_query($query);
$count=mysql_num_rows($result);
if($count==0)
{
mysql_query("UPDATE users SET username = '$_POST[username]',password = '$_POST[password]', role = '1', status = $_POST[status], allocatedmemory = '$_POST[allocatedmemory] $_POST[size]' WHERE userid = '$_POST[userid]'");
}
else
{
echo "<script language='javascript'>
alert('Username already exists');
</script>";
}
}
}
else if($_POST[btn] == 'Delete')
{
mysql_query("Delete from users where userid ='$_POST[userid]'");
echo "<script language='javascript'>
alert('Data Deleted');
</script>";
echo "<script language='javascript' type='text/javascript'>
window.close();
</script>";
}
}
?>
This is a big code as it is difficult to see all this,i can make it small for u to make clear my problem.so see the line no.14,34,85,86,92,99.
so wat i need to get is the value of line 86 after line 87. so that my condition in line no.99 can work
Thank u.