Jump to content

update gender and profile


ghqwerty

Recommended Posts

mysql_query("UPDATE members set gender = '".$gender."' and profile = '".$profile."' where id = '".$_SESSION['id']."'") or die(mysql_error());

 

thats the code im useing

 

echo $who_result['gender'];

 

and thats what im using to call the data however it isnt actually adding or updating the database

Link to comment
https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/
Share on other sites

the reason i would need to do this is because the gender is initially 'not available' then the user can change it to whatever they are

 

ok ill post all the code as that still doesnt work

$id = $_SESSION['id'];
								$who = "select * from members where id = '".$userid."'";
									$who_resulted = mysql_query($who);
										$who_result = mysql_fetch_array($who_resulted);
										$username = $who_result['username'];
								//make the table
								if($edit == "yes"){
								echo "<table id='profileedit' height='20%' width='35%' border='1'>
										<tr>
											<td colspan='3'>
												<center>
													player ".$username."
												</center>
											</td>
										</tr>
										<tr>
											<td colspan='2'>
												<center>
													statistics
												</center>
											</td>
											<td> 
												profile
											</td>
										</tr>
										<tr>
											<td>
												gender :
											</td>
											<td>												
												<form method='post' action='stats.php?uid=$userid'>
													male : <input type='radio' name='gender' value='male'>   female : <input type='radio' name='gender' value='female'>
											</td>
											<td rowspan='2'>
												<TEXTAREA NAME='profile' COLS='20' ROWS='10'></TEXTAREA>
											</td>
										</tr>
										<tr>
											<td colspan='2'>
												<input type='submit' name='editprofile' value='save changes'>
												</form>
											</td>
										</tr>
										</table>
										";
										if(isset($_POST['editprofile'])){
											$gender = $_POST['gender'];
											$profile = $_POST['profile'];
											$insert = "UPDATE members set gender = '".$gender."' where id = '".$_SESSION['id']."'";
											mysql_query("UPDATE members SET gender = '".$gender."' AND profile = '".$profile."' WHERE id = ".$_SESSION['id']) or die(mysql_error());
										}


								}else{
									echo "<table id='profile' height='20%' width='35%' border='1'>
										<tr>
											<td colspan='3'>
												<center>
													player ".$username."
												</center>
											</td>
										</tr>
										<tr>
											<td colspan='2'>
												<center>
													statistics
												</center>
											</td>
											<td> 
												profile
											</td>
										</tr>
										<tr>
											<td>
												level :  
											</td>
											<td>
												". $who_result['rank'] ."
											</td>
											<td rowspan='5'>
												profile
											</td>
										</tr>
										<tr>
											<td>
												name : 
											</td>
											<td>
												". $who_result['username']."
											</td>
										</tr>
										<tr>
											<td>
												class :
											</td>											
											<td>
												".$who_result['class']."
											</td>
										</tr>
										<tr>
											<td>
												gender :
											</td>
											<td>";
											if($who_result['gender'] != 'male' && $who_result['gender'] != 'female'){
												echo "not available";
											}else{
												echo $who_result['gender'];
											}

											echo "	</td>
										</tr>";

										if($userid == $_SESSION['id']){
											echo "<tr><td colspan='2'><a href='stats.php?uid=$userid&edit=yes'>edit profile</a></td></tr>";
										}

										echo "</table>";

}

hmm just took a step back and slowly thought it through and fixed it

 

what its doing is because ive made the action

 

 action='stats.php?uid=$userid'

when i click submit it goes back to the stats page so

 

if(isset($_POST['editprofile'])){

etc

 

will never happen because when its submitted it goes to the previous page

 

i fixed this by making the action

 action='stats.php?uid=$userid&edit=yes'

 

although could i just put the update code inside my other block so that when the user updates it takes him back to his profile not the edit ??

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.