обновяване на информация от дб

pro12

Registered
Имам код за редактиране на потребитетлски акаун.
Но не обновиава акаунта на потрелелия
Код:
      <? 
ob_start(); 
include("conff.php"); 
if ($logged[username]) 
{ 
// the user is logged in! We continue... 
if (!$_POST[update]) 
{ 
// the form hasn't been submitted. We continue... 
$profile = mysql_query("SELECT * from users where username = '$logged[username]'"); 
$profile = mysql_fetch_array($profile); 
// the above lines get the information so that it can be displayed in the html form. 
echo(" 
<center><form method=\"POST\"> 
<table width=\"100%\"> 
<tr> 
<td align=\"right\" width=\"25%\"> 
Location 
</td> 
<td align=\"left\"> 
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"$profile[location]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
MSN Messenger 
</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"msn\" value=\"$profile[msn]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
AOL Messenger</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"aim\" value=\"$profile[aim]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
Email адрес</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"email\" value=\"$profile[email]\"></td> 
</tr> 
<tr> 
<td align=\"center\"> 
</td> 
<td align=\"left\"> 
<input type=\"submit\" name=\"update\" value=\"Обнови\"></td> 
</tr> 
</table> 
</form> 
</center>"); 
} 
else 
{ 
$email = htmlspecialchars($_POST[email]); 
$aim = htmlspecialchars($_POST[aim]); 
$msn = htmlspecialchars($_POST[msn]); 
$locate = htmlspecialchars($_POST[locate]); 
// the above lines get rid of all html. 
echo ("Вашия профил е успешно обновен."); 
$update = mysql_query("Update users set email = '$email', 
msn = '$msn', aim = '$aim', location = '$locate' where username = '$logged[username]'"); 
// updates the information in the database. 
} 
} 
else 
{ 
// They aren't logged in! 
echo ("<a href=\"login.php\">Не сте логнат</a>"); 
} 
?>
 
<?
ob_start();
include("conff.php");
if ($logged[username])
{
// the user is logged in! We continue...
if (!$_POST[update])
{
// the form hasn't been submitted. We continue...
$profile = mysql_query("SELECT * from users where username = '$logged[username]'") or die(mysql_error());
$profile = mysql_fetch_array($profile);
// the above lines get the information so that it can be displayed in the html form.
echo("
<center><form method=\"POST\">
<table width=\"100%\">
<tr>
<td align=\"right\" width=\"25%\">
Location
</td>
<td align=\"left\">
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"$profile[location]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
MSN Messenger
</td>
<td align=\"left\">
<input size=\"25\" name=\"msn\" value=\"$profile[msn]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
AOL Messenger</td>
<td align=\"left\">
<input size=\"25\" name=\"aim\" value=\"$profile[aim]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
Email адрес</td>
<td align=\"left\">
<input size=\"25\" name=\"email\" value=\"$profile\"></td>
</tr>
<tr>
<td align=\"center\">
</td>
<td align=\"left\">
<input type=\"submit\" name=\"update\" value=\"Обнови\"></td>
</tr>
</table>
</form>
</center>");
}
else

}
else
{
// They aren't logged in!
echo ("<a href=\"login.php\">Не сте логнат</a>");
}
?>[/quote]

Сега какво казва? ;)
 
Пак същтото
Код:
<? 
ob_start(); 
include("conff.php"); 
if ($logged[username]) 
{ 
// the user is logged in! We continue... 
if (!$_POST[update]) 
{ 
// the form hasn't been submitted. We continue... 
$profile = mysql_query("SELECT * from users where username = '$logged[username]'"); 
$profile = mysql_fetch_array($profile); 
// the above lines get the information so that it can be displayed in the html form. 
echo(" 
<center><form method=\"POST\"> 
<table width=\"100%\"> 
<tr> 
<td align=\"right\" width=\"25%\"> 
Location 
</td> 
<td align=\"left\"> 
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"locate\" value=\"$profile[location]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
MSN Messenger 
</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"msn\" value=\"$profile[msn]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
AOL Messenger</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"aim\" value=\"$profile[aim]\"></td> 
</tr> 
<tr> 
<td align=\"right\" width=\"25%\"> 
Email адрес</td> 
<td align=\"left\"> 
<input size=\"25\" name=\"email\" value=\"$profile[email]\"></td> 
</tr> 
<tr> 
<td align=\"center\"> 
</td> 
<td align=\"left\"> 
<input type=\"submit\" name=\"update\" value=\"Обнови\"></td> 
</tr> 
</table> 
</form> 
</center>"); 
} 
else 
{ 
$email = htmlspecialchars($_POST[email]); 
$aim = htmlspecialchars($_POST[aim]); 
$msn = htmlspecialchars($_POST[msn]); 
$locate = htmlspecialchars($_POST[locate]); 
// the above lines get rid of all html. 
echo ("Вашия профил е успешно обновен."); 
$update = mysql_query("Update users set email = '$email', 
msn = '$msn', aim = '$aim', location = '$locate' where username = '$logged[username]'"); 
// updates the information in the database. 
} 
} 
else 
{ 
// They aren't logged in! 
echo ("<a href=\"login.php\">Не сте логнат</a>"); 
} 
?>
 
Пробвай да сложеш преди куерито
PHP:
echo "Update users set email = '$email',
msn = '$msn', aim = '$aim', location = '$locate' where username = '$logged[username]'";
и провери за грешки
второто е бих ти препоръчал когато пишеш куери имената на колоните ги слагаи в такива кавички `` за да нестават логически грешки
тоест
PHP:
$update = mysql_query(Update `users` set `email` = '$email',
`msn` = '$msn', `aim` = '$aim', `location` = '".$locate."' where `username` = '".$logged[username]."'");
 

Back
Горе