dark dude Posted June 23, 2006 Share Posted June 23, 2006 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~ Quote Link to comment https://forums.phpfreaks.com/topic/12764-what-am-i-doing-wrong/ Share on other sites More sharing options...
Eric_Ryk Posted June 23, 2006 Share Posted June 23, 2006 [!--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:<?phpsession_start();?> Quote Link to comment https://forums.phpfreaks.com/topic/12764-what-am-i-doing-wrong/#findComment-48921 Share on other sites More sharing options...
phpstuck Posted June 23, 2006 Share Posted June 23, 2006 $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.'; } Quote Link to comment https://forums.phpfreaks.com/topic/12764-what-am-i-doing-wrong/#findComment-48930 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.