Re: Getting user name in text area
| From: | James Taylor | Date: | Thu, 28 Mar 2002 23:00:28 +0000 |
| Subject: | Re: Getting user name in text area | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90605@lists.php.net to get a copy of this message | ||
Well, let's see here..
$query = mysql_query("select name from users where uid = {$_SESSION['uid']}", $db);
while ($name = mysql_fetch_row($query) {
echo "<BR /><BR /><BR />$name[0]\n";
}
hope that helps
Jennifer Downey wrote:
Hi all, Here is what I have and what I am trying to do. I would like the user name to be printed in the Username text box but can't seem to get it there. I don't want the user to have to type there username in, just click the submit button and it is entered into the db. Can anyone show me what I have done wrong? $query="SELECT name FROM users WHERE uid={$session["uid"]}"; $ret = mysql_query($query); while(list($name)= mysql_fetch_row($ret)) print("<BR><BR><BR>$name"); ?> <table ALIGN="center" WIDTH="80%"><tr> <td><form ACTION="<?php echo($PHP_SELF);?>" METHOD=post> <? print "<td><br>Username: <input type=\"text\" value=\"$name\" name=\"u_name\" size=30></td></tr><tr><td>"; print "<input TYPE=\"submit\" name=\"action\" VALUE=\"Submit my entry\"></center><br><br>"; ?> </form></td></tr> </table> <? if($action = "Submit my entry"){ if (!empty($name)){ $enter = "insert into entry (id, user_name) values ('','$u_name')"; mysql_query($enter) or die(mysql_error()); } } TIA Jennifer