Jump to content


Photo

What AM I doing wrong?


  • Please log in to reply
2 replies to this topic

#1 dark dude

dark dude
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 23 June 2006 - 09:09 PM

Ok, i'm trying to create a form where you can update your profile information, or in otherwords, update the data under your logged in field on the database using a script.

So far, i've done these scripts:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<body bgcolor='#000033' text='#CCFFFF'>
<?
session_start();

$Username=$_SESSION['Username'];

include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);

$query = "SELECT * FROM Users WHERE Username='$Username'";
$result = mysql_query($query) or die(mysql_error());

$Password=mysql_result($result,$i,"Password");
$Email=mysql_result($result,$i,"Password");
?>

<form action="updated.php" method="post">
<input type="hidden" name="ud_Username" value="<? echo $Username; ?>">
Current Username: <? echo $Username; ?><br>
Current Email Address: <? echo $Email; ?><br><br>
New Username: <input type="text" name="ud_Username" value="<? echo $Username; ?>"><br>
New Password: <input type="text" name="ud_Password" value="<? echo $Password; ?>"><br>
New Email Address: <input type="text" name="ud_Email" value="<? echo $Email; ?>"><br>
<input type="Submit" value="Update">
</form>[/quote]

And this is the updated.php script:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
<?
session_start();

$Username=$_SESSION['Username'];

$ud_Username=$_POST['ud_Username'];
$ud_Password=$_POST['ud_Password'];
$ud_Email=$_POST['ud_Email'];

include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);


$query="UPDATE Users SET Username='$ud_Username', Password='$ud_Password', Email='$ud_Email' WHERE Username='$Username'";
mysql_query($query);
echo "Record Updated";

?>[/quote]

It doesnt seem to work, though it seems right.

What am I doing wrong, and how do I make it work properly?


Thanks,
~Dark dude~

#2 Eric_Ryk

Eric_Ryk
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 23 June 2006 - 09:25 PM

[!--quoteo(post=387296:date=Jun 23 2006, 05:09 PM:name=Dark dude)--][div class=\'quotetop\']QUOTE(Dark dude @ Jun 23 2006, 05:09 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Ok, i'm trying to create a form where you can update your profile information, or in otherwords, update the data under your logged in field on the database using a script.

So far, i've done these scripts:
And this is the updated.php script:
It doesnt seem to work, though it seems right.

What am I doing wrong, and how do I make it work properly?
Thanks,
~Dark dude~
[/quote]
session_start needs to be done before anything (even just a space) is sent to the page. So right at the very beginning:
<?php
session_start();
?>

#3 phpstuck

phpstuck
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 23 June 2006 - 10:02 PM

$sql = mysql_query("UPDATE Users SET Username='$ud_Username', Password='$ud_Password', Email='$ud_Email' WHERE Username='$Username'";
mysql_query($query);

if(!$sql){
echo 'A database error occured while creating your account. Please contact support.';
}




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users