beansandsausages Posted July 31, 2007 Share Posted July 31, 2007 Im trying to make a form where if you click edit it lets you change a username, it kinda works it lets you pick a name but when it sends the name to the data base it just leaves it blank :-\ code is below echo " <Tr><Td>Username <td>:<td>$info[username] <a href=cont.php?edit=username>Edit</a></td> "; if($_GET[edit] == "username") { echo " <tr><Td> <input type =text name=name value='$info[username]'> <td> : <td> <a href=cont.php?edit=saveusername>Save</a> </td> "; } if($_GET[edit] == "saveusername" ) { $username = str_replace(">", ">", $username); $username = str_replace("<", "<", $username); $check1 = mysql_query("SELECT username FROM users WHERE username='$_GET[name]'"); if ((mysql_num_rows($check1) != 0)) { echo 'Sorry, name already in use<br>'; } else { $updateuserdb = mysql_query("update users set username='$_GET[name]' where id=$info[id]"); echo "You have changed your username.<br>"; } } Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/ Share on other sites More sharing options...
Psycho Posted July 31, 2007 Share Posted July 31, 2007 Doesn't look like you have a link to do the saveusername action, but I don't see how you are passing the value of the usrname field to the page, or the userid for that matter. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312064 Share on other sites More sharing options...
beansandsausages Posted July 31, 2007 Author Share Posted July 31, 2007 there is a link to the saveusername, and passing the variables in the input field. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312067 Share on other sites More sharing options...
mdnghtblue Posted July 31, 2007 Share Posted July 31, 2007 I'm not sure you can pass variables like that...I might be wrong. If you want to pass the variable with a URL, I think it has to be part of the URL. Otherwise, put the input field in a form, and use a submit button. That will definitely work. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312071 Share on other sites More sharing options...
beansandsausages Posted July 31, 2007 Author Share Posted July 31, 2007 guess ill have to use the form i dont like them though lol. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312073 Share on other sites More sharing options...
Psycho Posted July 31, 2007 Share Posted July 31, 2007 You could use a javascript function to run when clicking a link that would create the link with the appropriate parameters. But, a form would be a better option. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312245 Share on other sites More sharing options...
calabiyau Posted July 31, 2007 Share Posted July 31, 2007 $check1 = mysql_query("SELECT username FROM users WHERE username='$_GET[name]'"); the line above and all your queries for that matter, you don't have single quotes within your GET variables, should be $_GET['name']. All your queries are like that. Link to comment https://forums.phpfreaks.com/topic/62701-just-a-quick-one/#findComment-312261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.