burnside 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>"; } } Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
burnside 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
burnside Posted July 31, 2007 Author Share Posted July 31, 2007 guess ill have to use the form i dont like them though lol. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.