Jump to content

What AM I doing wrong?


dark dude

Recommended Posts

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~
Link to comment
Share on other sites

[!--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) [snapback]387296[/snapback][/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();
?>
Link to comment
Share on other sites

$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.';
}
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.