[SOLVED] What is wrong here

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

[SOLVED] What is wrong here

Post 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>
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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()?
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

Any other opinions?
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

Do what feyd said and tell us the result.
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post 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??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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; 
}
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

:idea:
Last edited by g3ckO on Thu Jul 15, 2004 1:50 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$HTTP_POST_VARS['user'] isn't set. However, it looks like $_POST['user'] is..
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

OK.. That solved my problem. :)
Tq very much feyd.
Post Reply