Page 1 of 1

[SOLVED] What is wrong here

Posted: Wed Jul 14, 2004 11:56 pm
by g3ckO
Hye..
Anyone can tell me what is wrong here.

The $ID and $pass doesn't appear in my table.

This is my form code:

Code: Select all

<?php
<hr><br>
<font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
<center>Enter <b>username</b> you want to <b>EDIT/DELETE</b>

<form action="edit_user_func.php" method="post"> 

<div align="center"><center>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
    	<tr>
        <td align="center" valign="bottom" width="50%"
            bgcolor="#FFFFFF" valign="TOP" marginwidth="12" marginheight="12">

            <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
            <b>Username</b></font>
        </td>
        <td align="center" valign="top" width="50%"
            bgcolor="#FFFFFF" marginwidth="12" marginheight="12">
            <input type="text" size="20" name="user" maxlength="30" >
        </td>
    	</tr>
</table></center></div>
	<br><input type="submit" value="EDIT/DELETE" name="edit"></form>
	<form action="homeAdmin.php" method="post">
   	<input type="submit" value="BACK" name="Back"><br></form>
<hr>
?>
edit_user_func.php

Code: Select all

<?php
<?

include("database.php");

function get_user()
{
   $user = $HTTP_POST_VARS['user'];
   $query = "SELECT * FROM employee WHERE username = '$user'";      
   $result = mysql_query($query);
   $row_array = mysql_fetch_array($result);	
   return $row_array;
}

echo"Below is the $user information";

   $row_array=get_user(); 
   $ID=$row_array['username']; 
   $Pass=$row_array['password'];
?>
?> 

<hr>
   <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
   <center><b>*****************************************</b></font></center>
   <hr>
   <div align="center"><center>
   <table border="1" cellpadding="2" cellspacing="1" width="100%">
    	<tr>
        <td align="left" valign="bottom" width="30%"
            bgcolor="#FFFFFF" valign="TOP" marginwidth="12" marginheight="12">

            <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
            <b>Username</b></font>
        </td>
   <td align="left" valign="top" width="70%"
            bgcolor="#FFFFFF" marginwidth="12" marginheight="12">
	    
	    <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
            <b><?echo "$ID";?></b></font>
        </td>
    	</tr>
   </table>

   <div align="center"><center>
   <table border="1" cellpadding="2" cellspacing="1" width="100%">
    	<tr>
        <td align="left" valign="bottom" width="30%"
            bgcolor="#FFFFFF" valign="TOP" marginwidth="12" marginheight="12">

            <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
            <b>Password</b></font>
        </td>
   <td align="left" valign="top" width="70%"
            bgcolor="#FFFFFF" marginwidth="12" marginheight="12">
	    
	    <font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
            <b><?echo "$Pass";?></b></font>
        </td>
    	</tr>
   </table>
?>

Posted: Thu Jul 15, 2004 12:25 am
by feyd
have you tried echoing $query inside the function? have you determined that short tags are on? have you printed the results coming from get_user()?

Posted: Thu Jul 15, 2004 12:59 am
by g3ckO
Any other opinions?

Posted: Thu Jul 15, 2004 1:09 am
by andre_c
Do what feyd said and tell us the result.

Posted: Thu Jul 15, 2004 1:14 am
by g3ckO
short tags is on.

echoing $query inside the function? How?

The code that I write is to print the function. It is true??

Posted: Thu Jul 15, 2004 1:23 am
by feyd

Code: Select all

function get_user() 
{ 
   $user = $HTTP_POST_VARS['user']; 
   echo $query = "SELECT * FROM employee WHERE username = '$user'";      
   $result = mysql_query($query) or die(mysql_error()); 
   $row_array = mysql_fetch_array($result);
   print_r($row_array);
   print_r($_SERVER);
   print_r($_POST);
   return $row_array; 
}

Posted: Thu Jul 15, 2004 1:31 am
by g3ckO
:idea:

Posted: Thu Jul 15, 2004 1:38 am
by feyd
$HTTP_POST_VARS['user'] isn't set. However, it looks like $_POST['user'] is..

Posted: Thu Jul 15, 2004 1:46 am
by g3ckO
OK.. That solved my problem. :)
Tq very much feyd.