Jump to content


Photo

Have problem with passing a variable


  • Please log in to reply
2 replies to this topic

#1 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 03 June 2003 - 12:32 PM

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
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 03 June 2003 - 01:03 PM

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

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 03 June 2003 - 06:33 PM

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?? :?: :?:
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users