vaan Posted June 3, 2003 Share Posted June 3, 2003 Hi, Everyone helped me out on the insert question but i now have a update question When i press submit in this script it updates.. but it just makes 1 time a new row.. With the update i made.. Every time i try to update it again it just updates that row... But not the username i sended with update1.php?userid=admin Do you still get it?? I really can\'t fix it :roll: Here is my code [php:1:6b0552874a] <HEAD> <? include \"include/db.php\";?> <TITLE>UPDATE USER</TITLE> </HEAD> <BODY> <? $userid = $_GET[\'userid\']; $server = \"$host\"; $mysql_user = \"$user\"; $mysql_password = \"$pass\"; $database = \"$db\"; $link = mysql_connect($server, $mysql_user, $mysql_password) or die(\"Could not connect to mysql!<br />mysql error: \" . mysql_error()); // Selecting databse mysql_select_db ($database, $link) or die(\"Could not select db!<br />mysql error: \" . mysql_error()); if ($sent){ print(\"<BR><BR><CENTER>THE USER IS UPDATED<BR>updated user:<BR>$userid <BR>new password:<BR>$password<BR><BR>new userlevel:<BR>$userlevel<BR><BR>new webspace:<BR>$webspace<BR><BR>\"); } else { print(\"<BR><BR><CENTER><BR><BR><BR><FORM ACTION=update1.php METHOD=post> Username: $userid<BR> Password: <INPUT TYPE=PASSWORD NAME=password class=button><BR> Email adress: <INPUT TYPE=TEST NAME=email class=button><BR> Fullname <INPUT TYPE=TEST NAME=name class=button><BR> Package: <select name=userlevel> <option value=basic>basic</option> <option value=medium>medium</option> <option value=large>large</option> <option value=reseller>reseller</option> <option value=admin>admin</option> </select> <BR> Webspace: <INPUT TYPE=TEST NAME=webspace class=button><BR> <BR><BR><INPUT TYPE=SUBMIT VALUE=SUBMIT NAME=sent class=button></FORM><BR><BR><BR>\"); } if ($sent){ $userid = $_GET[\'userid\']; $sql2 = \"update user set password = \'$password\' where userid = \'$userid\'\"; $result = mysql_query($sql2) or die(\"Couldn\'t execute query.1\"); $sql3 = \"update user set userlevel = \'$userlevel\' where userid = \'$userid\'\"; $result = mysql_query($sql3) or die(\"Couldn\'t execute query.2\"); $sql3 = \"update user set webspace = \'$webspace\' where userid = \'$userid\'\"; $result = mysql_query($sql3) or die(\"Couldn\'t execute query.3\"); $sql3 = \"update user set fullname = \'$name\' where userid = \'$userid\'\"; $result = mysql_query($sql3) or die(\"Couldn\'t execute query.4\"); $sql3 = \"update user set email = \'$email\' where userid = \'$userid\'\"; $result = mysql_query($sql3) or die(\"Couldn\'t execute query.5\"); $sql3 = \"update user set userid = \'$userid\' where userid = \'$userid\'\"; $result = mysql_query($sql3) or die(\"Couldn\'t execute query.6\"); print (\"Users Info Successfully Updated!\"); } ?> </BODY></HTML> [/php:1:6b0552874a] thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/540-have-problem-with-passing-a-variable/ Share on other sites More sharing options...
shivabharat Posted June 3, 2003 Share Posted June 3, 2003 why so many updates use this? "update user set password = \'$password\' ,userlevel = \'$userlevel\' ,webspace = \'$webspace\' ,fullname = \'$name\' ,email = \'$email\' ,userid = \'$userid\' where userid = \'$userid\'" also do a echo on the top and see if u can see the userid if it doesnt .....try $userid = $_POST[\'userid\']; Quote Link to comment https://forums.phpfreaks.com/topic/540-have-problem-with-passing-a-variable/#findComment-1816 Share on other sites More sharing options...
vaan Posted June 3, 2003 Author Share Posted June 3, 2003 no it doesn\'t echo the username. Also not with the code you said.. This is how i send the username in.. update1.php?userid=admin Does anyone see the problem. And can anyone tell me how to show the things i allready putted in the database in my input fields?? :?: :?: Quote Link to comment https://forums.phpfreaks.com/topic/540-have-problem-with-passing-a-variable/#findComment-1818 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.