andrew_biggart Posted March 3, 2009 Share Posted March 3, 2009 Ok ive been trying for days to ge this sorted and it is driving me up the walls please please please someone put me out of my missery lol. Im trying to do the edit profile section of my site, sounds simple enough when you have some php knowledge, so the page loads, all the current info is echoed in the correct input boxes no problem. This is the form page <table class="myprofile_change"> <tr><td class="myprofile_changesh">Edit Profile</td></tr> <tr><td class="myprofile_subtext2">Scroll down, complete the fields, then click Save Changes to update your profile. All of the following questions are optional, but you must answer a minimum of 5 to appear in our search results.</td></tr> <tr><td></td></tr> </table> <br /> <table> <tr><td class="myprofile_changesh">General Info ...</td></tr> </table> <form method="post" action="my_profile_edit_submit.php"> <?php include("config.php"); // Retrieve data from database $sql="SELECT * FROM User_infoT WHERE Username='".$_SESSION["myusername"]. "'"; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <table class="myprofile_change"> <tr><td class="myprofile_subtext">Location :</td><td><input name="Location" id="Location" type="text" value="<? echo $rows['Location']; ?>" /></td></tr> <tr><td class="myprofile_subtext">Favourite smoking method :</td> <td><select name="Fav" id="Fav"style="width: 126px"> <option>Choose</option> <option>Joint</option> <option>Blunt</option> <option>Tulip</option> <option>Bong</option> <option>Lung</option> <option>Bucket</option></select></td></tr> <tr><td class="myprofile_subtext">Favourite quote :</td><td><input name="Quote" id="Quote"type="text" style="width: 246px" maxlength="50 "value="<? echo $rows['Quote']; ?>" /></td><td class="myprofile_max">Max 50 characters</td></tr> <tr><td></td></tr> </table> <br /> <table> <tr><td class="myprofile_changesh">About me ...</td></tr> </table> <br /> <table> <tr><td class="myprofile_subtext">About Yourself :</td><td rowspan="2"><textarea name="Aboutme" id="Aboutme" style="width: 415px; height: 135px"><? echo $rows['Aboutme']; ?></textarea></td></tr> <tr><td class="myprofile_max2">Use <br /> to separate paragraphs instead of using the return button</td></tr> </table> <br /> <table class="myprofile_change"> <tr><td class="myprofile_subtext">Why do you love weed? :</td> <td rowspan="2"><textarea name="Whywe" id="Whywe" style="width: 415px; height: 135px" ><? echo $rows['Whywe']; ?></textarea></td></tr> <tr><td class="myprofile_max2">Use <br /> to separate paragraphs instead of using the return button</td></tr> <tr><td></td></tr> </table> <br /> <table> <tr><td class="myprofile_changesh">Personal info ...</td></tr> </table> <br /> <table class="myprofile_change"> <tr><td class="myprofile_subtext">Interests :</td><td><input name="Interests" id="Interests" type="text" style="width: 246px" value="<? echo $rows['Interests']; ?>" /></td><td class="myprofile_max">Max 50 characters</td></tr> <tr><td class="myprofile_subtext">Makes me happy :</td><td><input name="Happy" id="Happy"type="text" style="width: 246px" value="<? echo $rows['Happy']; ?>"/></td><td class="myprofile_max">Max 70 characters</td></tr> <tr><td class="myprofile_subtext">Makes me sad :</td><td><input name="Sad" id="Sad"type="text" style="width: 246px" value="<? echo $rows['Sad']; ?>" /></td><td class="myprofile_max">Max 70 characters</td></tr> <tr><td class="myprofile_subtext">Bad habits :</td><td><input name="Habits" id="Habits"type="text" style="width: 246px" value="<? echo $rows['Habits']; ?>" /></td><td class="myprofile_max">Max 60 characters</td></tr> <tr><td></td></tr> </table> <br /> <table> <tr><td class="myprofile_changesh">Favourite things ...</td></tr> </table> <br /> <table class="myprofile_change"> <tr><td class="myprofile_subtext">Music :</td><td><select id="Music"name="Music" style="width: 126px"> <option>Choose</option> <option>Dance</option> <option>RnB</option> <option>Funky House</option> <option>Indie</option> <option>Rock</option> <option>Electro</option> <option>Chillout</option> </select></td></tr> <tr><td class="myprofile_subtext">Movies :</td><td><input name="Movie" id="Movie"type="text" style="width: 246px" value="<? echo $rows['Movie']; ?>" /></td><td class="myprofile_max">Max 100 characters</td></tr> <tr><td class="myprofile_subtext">Website :</td><td><input name="Website" id="Website"type="text" style="width: 246px" value="<? echo $rows['Website']; ?>"/></td><td class="myprofile_max">No spamming</td></tr> <tr><td></td></tr> </table> <? // close while loop } // close connection mysql_close(); ?> <br /> <table> <tr><td class="myprofile_changesh">Save the changes to your profile ...</td></tr> <tr><td></td></tr> <tr><td></td></tr> </table> <br /> <table class="myprofile_change"> <tr><td><input name="Submit1" type="submit" value="Change that shit !" /></td></tr> </table> <br /> <br /> <br /> <br /> <br /> <br /> </form> But when i the form is submitted, after changing loads of things trying everything i either get one of three results. 1. The form changes the information for every user to the updated information. 2. the classic blanc screen. 3. An internal server error. the php i am using to try to update the new information is as follows. <?php include("config.php"); $Location = ($_POST['Location']); $Fav = ($_POST['Fav']); $Quote = ($_POST['Quote']); $Interests = ($_POST['Interests']); $Happy = ($_POST['Happy']); $Sad = ($_POST['Sad']); $Habits = ($_POST['Habits']); $Music = ($_POST['Music']); $Movie = ($_POST['Movie']); $Website = ($_POST['Website']); $Aboutme = ($_POST['Aboutme']); $Whywe = ($_POST['Whywe']); $sql = "UPDATE User_infoT SET Location='$Location', Fav='$Fav', Quote='$Quote', Interests='$Interests', Happy='$Happy', Sad='$Sad', Habits='$Habits', Music='$Music', Movie='$Movie', Website='$Website', Aboutme='$Aboutme', Whywe='$Whywe' WHERE Username='".$_SESSION["myusername"]."' LIMIT 1"; $result=mysql_query($sql) or die(mysql_error().": $sql"); if($result){ header("my_profile.php"); } else { header("profile_edit.php"); } // close connection mysql_close(); ?> I cannot seem to figure this out on my own and i hope i have explained it well enough to spot an error. Thanks for your help Quote Link to comment Share on other sites More sharing options...
trq Posted March 3, 2009 Share Posted March 3, 2009 I don't see any call to session_start in the second page yet you are using the $_SESSION array. Quote Link to comment Share on other sites More sharing options...
andrew_biggart Posted March 3, 2009 Author Share Posted March 3, 2009 ok i have added that lol that would help but it still isnt working grrrrrr <?php session_start(); if(!session_is_registered(myusername)){ header("location:under_construction.htm"); } ?> <?php include("config.php"); $Location = ($_POST['Location']); $Fav = ($_POST['Fav']); $Quote = ($_POST['Quote']); $Interests = ($_POST['Interests']); $Happy = ($_POST['Happy']); $Sad = ($_POST['Sad']); $Habits = ($_POST['Habits']); $Music = ($_POST['Music']); $Movie = ($_POST['Movie']); $Website = ($_POST['Website']); $Aboutme = ($_POST['Aboutme']); $Whywe = ($_POST['Whywe']); $sql = "UPDATE User_infoT SET Location='$Location', Fav='$Fav', Quote='$Quote', Interests='$Interests', Happy='$Happy', Sad='$Sad', Habits='$Habits', Music='$Music', Movie='$Movie', Website='$Website', Aboutme='$Aboutme', Whywe='$Whywe' WHERE Username='".$_SESSION["myusername"]."' LIMIT 1"; $result=mysql_query($sql) or die(mysql_error().": $sql"); if($result){ header("my_profile.php"); } else { header("profile_edit.php"); } // close connection mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 3, 2009 Share Posted March 3, 2009 session_is_registered has long been depricated and you have an undefined constant in this piece of code anyway... if(!session_is_registered(myusername)){ header("location:under_construction.htm"); } I would replace that with.... if (!isset($_SESSION['myusername'])) { header("location: under_construction.htm"); } Besides that, are you getting any errors? Quote Link to comment Share on other sites More sharing options...
andrew_biggart Posted March 3, 2009 Author Share Posted March 3, 2009 This is the new code i am using now. <?php session_start(); if (!isset($_SESSION['myusername'])) { header("location: under_construction.htm"); } ?> <?php include("config.php"); $Username = ($_SESSION["myusername"]); $Location = ($_POST['Location']); $Fav = ($_POST['Fav']); $Quote = ($_POST['Quote']); $Interests = ($_POST['Interests']); $Happy = ($_POST['Happy']); $Sad = ($_POST['Sad']); $Habits = ($_POST['Habits']); $Music = ($_POST['Music']); $Movie = ($_POST['Movie']); $Website = ($_POST['Website']); $Aboutme = ($_POST['Aboutme']); $Whywe = ($_POST['Whywe']); $sql = "UPDATE User_infoT SET Location='$Location', Fav='$Fav', Quote='$Quote', Interests='$Interests', Happy='$Happy', Sad='$Sad', Habits='$Habits', Music='$Music', Movie='$Movie', Website='$Website', Aboutme='$Aboutme', Whywe='$Whywe' WHERE Username='Username' LIMIT 1"; $result=mysql_query($sql) or die(mysql_error().": $sql"); if($result){ header("my_profile.php"); } else { header("profile_edit.php"); } // close connection mysql_close(); ?> and this is the error i get on my screen now with this code. Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@server.microlite20.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. which is no help what so ever but the rest of my site is php and it works fine, the only bit i cant get to work is the edit profile bit Quote Link to comment Share on other sites More sharing options...
andrew_biggart Posted March 3, 2009 Author Share Posted March 3, 2009 Any ideas anyone? im gonna jump out the window in aminute lol Quote Link to comment 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.