Jump to content

Have problem with passing a variable


vaan

Recommended Posts

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

Link to comment
Share on other sites

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\'];  

Link to comment
Share on other sites

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?? :?: :?:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.