Jump to content

[SOLVED] Last bit of help for a bit


Leveecius

Recommended Posts

So I am trying to figure this out.    On my game I have it to where you can edit your own profile quote and mood/status.  However, I have someone saying that they are having issues that when they try to change their mood, it changes their quote, so did I write this wrong?  Here is how I have it written:

 

if ($_POST['editquote']){
$detail=$_POST['content'];

mysql_query("UPDATE users SET quote = '$detail' WHERE username='$username'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` ) VALUES ('', '$username', 'Edited profile!', '$date')");
echo "Your quote has been successfully updated!";
}

if ($_POST['newmood']){
$detail=$_POST['content'];

mysql_query("UPDATE users SET mood = '$detail' WHERE username='$username'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` ) VALUES ('', '$username', 'Updated Mood!', '$date')");
echo "Your mood has been successfully updated!";
}

 

Is that wrong?  If so, I change the content and $detail to content2 and $detail 2 for mood, and both times it won't write to my database with the 2's behind them

Link to comment
https://forums.phpfreaks.com/topic/179887-solved-last-bit-of-help-for-a-bit/
Share on other sites

I see why.

 

if ($_POST['editquote']){

$detail=$_POST['content'];

 

if ($_POST['newmood']){

$detail=$_POST['content'];

 

Shouldn't you be using another $_POST variable for $detail under newmood or editquote?  Eitherway you are storing something where it doesn't belong.

keep in mind, it's rough to say the least, as it's for my BETA game.

 

<?
session_start();  

if (!(isset($_SESSION["real_name"])))
{
//echo "I'm not logged in";
header('Location: index.php');
}
else
{
echo "";
}


?>



<html>
<head>
<title>Mafia Syndicate BETA</title></head>
    	<link REL="stylesheet" TYPE="text/css" HREF="main.css">

<script language=javascript src=Menus.js></script>

<body background="wallpaper.jpg">
<center> 
<table border="0" cellspacing="0" cellpadding="0" align="center" width="95%" class="cat">

<TR> 

<TD width="150" background="tdbg3.jpg" bgcolor="#222222" valign="top">
<?php include("leftmenu.php");?>
</TD>
  
    <td width="100%" valign="top">	<br>	




<br>
<?php
include "includes/db_connect.php"; 

$username=$_SESSION["real_name"];


if ($_POST['changepass']){
$pass=$_POST['password'];
$newpass=$_POST['newpass'];

if ($mypassword == $pass){

mysql_query("UPDATE users SET password = '$newpass' WHERE username='$username'");
session_destroy(); 
echo "Your Password has been successfully updated!";

}else{

echo "Incorrect Password!";

}

}


if ($_POST['hide']){

mysql_query("UPDATE users SET online='Offline' WHERE username='$username'");

echo "You are now appearing offline!";

}

if ($_POST['editquote']){
$detail=$_POST['content'];

mysql_query("UPDATE users SET quote = '$detail' WHERE username='$username'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` ) VALUES ('', '$username', 'Edited profile!', '$date')");
echo "Your quote has been successfully updated!";
}

if ($_POST['newmood']){
$detail=$_POST['content'];

mysql_query("UPDATE users SET mood = '$detail' WHERE username='$username'");
mysql_query("INSERT INTO `logs` ( `id` , `who` , `action` , `date` ) VALUES ('', '$username', 'Updated Mood!', '$date')");
echo "Your mood has been successfully updated!";
}

if ($_POST['update300']){

$image1=$_POST['imageurl1'];


function change($msg){
$post = $msg;
$post = str_replace(".php", "", $post); 
return $post;
}

$image1=change($image1);

mysql_query("UPDATE users SET 300x300 = '$image1' WHERE username='$username'");

echo "Your 200x200 picture has been successfully updated!";  
}


$sql="SELECT * from users WHERE username='$username'";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){ // Start looping table row 

$id=$rows['id'];
$input=$rows['300x300'];

$input = str_replace("http://", '', $input); 

?>
<form action="" method="post">
  <table border=1 cellspacing=0 align="center" cellpadding=2 width=80% bordercolor=black class=sub2>
  <tr>
  <td class="header" colspan="2" align="center">Personal Statistics</td>
  </tr>
  <tr>
  <td>Registration E-mail:</td>
  <td><? echo $rows['email']; ?></td>
  </tr>
  <tr>
  <td>Total GTA's</td>
  <td><? echo $rows['totalgta']; ?></td>
  </tr>
    <tr>
  <td>Total Crimes</td>
  <td><? echo $rows['totalcrimes']; ?></td>
  </tr>
      <tr>
  <td>Total Chase</td>
  <td><? echo $rows['totalchase']; ?></td>
  </tr>
    <tr>
  <td>Total Jailbust</td>
  <td><? echo $rows['totalbusts']; ?></td>
  </tr>
      <tr>
  <td>Total Organized Crimes</td>
  <td><? echo $rows['totaloc']; ?></td>
  </tr>
  <tr>
  <td>Total Kills:</td>
  <td><? echo $rows['totalkills']; ?></td>
  </tr>
  <? if ($userlevel>=10){ ?>
  <tr>
  <td colspan="2" align="center">
  <input type="submit" name="hide" value="Appear Offline">
  </td>
  </tr>
  <? } ?>
  </table>
    <br><br>
  <table border=1 cellspacing=0 align="center" cellpadding=2 width=80% bordercolor=black class=sub2>
  <tr>
   <td class="header" colspan="2" align="center">Personal Quote</td>
  </tr>
  <tr>
  <td valign=top>Quote:</td>
  <td><textarea name="content" cols='' style='width: 99%; border:1px solid black; height: 300px;'><? echo $rows['quote']; ?></textarea></td>
  </tr>
  <tr>
  <td> </td><td align=right><center><input name="editquote" type=submit value="Update!"></center></td>
  </tr>
  <tr><td align="center" colspan="2">
    <a href="viewprofile.php?viewuser=<? echo $rows['username']; ?>">View Your Profile!</a> || <a href="showcars.php?id=<? echo $id ?>">Show</a>/<a href="removecars.php?id=<? echo $id ?>">Remove</a> Cars On Your Profile!

</td></tr>
  </table>
  
  <br><br>
<table border=1 cellspacing=0 align="center" cellpadding=2 width=80% bordercolor=black class=sub2>
  <tr>
   <td class="header" colspan="2" align="center">Personal Mood</td>
  </tr>
  <tr>
  <td valign=top>Current Mood:</td>
  <td><textarea name="content" cols='' style='width: 99%; border:1px solid black; height: 20px;'><? echo $rows['mood']; ?></textarea></td>
  </tr>
  <tr>
  <td> </td><td align=right><center><input name="newmood" type=submit value="Update!"></center></td>
  </tr>
  </table>
    <br><br>

   <table border=1 cellspacing=0 cellpadding=2 align="center" width=60% bordercolor=black class=sub2>
  <tr>
  <td class="header" colspan="2" align="center">Change your password</td>
  </tr>
  <tr>
  <td>New Password:</td><td><input type=password style="border:1px solid black;" name=newpass></td>
  </tr>
  <tr>
  <td>Confirm Password:</td><td><input type=password style="border:1px solid black;" name=newpass></td>
  </tr>
  <tr>
  <td>Current Password:</td><td><input type=password style="border:1px solid black;" name=password></td>
  </tr>
  <tr>
  <td> </td><td align=right><input name="changepass" type=submit value="Change!"></td>
  </tr>
  </table>
  <br><br>

<table border=1 cellspacing=0 align="center" cellpadding=2 width=75% bordercolor=black class=sub2>
  <tr>
  <td class="header" colspan="2" align="center">Side Picture</td>
  </tr>
  <tr>
  <td class="header" colspan="2" align="center">Current Image</td>
  </tr>
  <tr><td align="center">
  <img src="http://<? echo htmlspecialchars($input); ?>" border="3" width=200 height=200></td></tr>
   
  
  <tr>
  <td align=center><font color="#ffffff" size="1">Image 1:</font> <input style="border:1px solid black;" type=text name=imageurl1 value="http://<? echo htmlspecialchars($input); ?>" size=50></td>
  </tr>
  <tr>
  <td align=right><input type=submit value="Update!" name="update300"></td>
  </tr>
  </table>
  </form>
<?php
// Exit looping and close connection 
}

?>

<br><br><br>


</td>



  	  <TD width="150" valign="top">
<?php include("rightmenu.php");?>
</TD>

</TR>


</table>

</center>
</body>
</html>

That's what I thought it was.  You have to inputs in your form with the same name.  For you quote textarea, rename it from "content" to "quote" and the textarea name for mood from "content" to "mood".

 

<tr>
  <td valign=top>Quote:</td>
  <td><textarea name="content" cols='' style='width: 99%; border:1px solid black; height: 300px;'><? echo $rows['quote']; ?></textarea></td>
  </tr>

 

<tr>
  <td valign=top>Current Mood:</td>
  <td><textarea name="content" cols='' style='width: 99%; border:1px solid black; height: 20px;'><? echo $rows['mood']; ?></textarea></td>
  </tr>

 

Don't forget to update your form handler to reflect the new names.

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.