witam
na poczatku wspomnie ze o ajax nie wiem nic, zwracam sie do was poniewaz sciagnolem gotowca z tej strony panelu kontrolnego.
I tam jest tez ajax zawarty dla edycji profilu uzytkownika. I brakuje mi edycje wpisow jakie ten uzytkownik dokona. Czy uwazacie ze powinienem uzyc do edycji wpisu ajax czy innej mozliwosci?

pozdrawiam
Mariusz

widze ze nikt mi nie odpowiada na moje pytanie to pokaze troche kodu:

kod ktory po sprawdzeniu logowania wyswietli wpisy ktore dokonal uzytkownik:
  1. <?php
  2. $wynik=mysql_query("SELECT * FROM `obiekty` WHERE `iduzyt`='{$user['id']}'");
  3. while ($wiersz = mysql_fetch_array($wynik))
  4. {
  5. if ($wiersz['id']!=$tablica[0])
  6. {
  7. echo '<table width="600" align="center">
  8. <tr>
  9. <td width="600" height="170"><br><br style="line-height:10px" /><center>
  10. <table width="600" height="170" border=1 bordercolor=darkgray cellspacing="2" cellpadding="5" rules=none>
  11. <tr>
  12. <td width="100" rowspan=8 width="5" valign="middle" cellspacing="2">
  13. <img class="obiekt" src="'.(($wiersz['url1'])?$wiersz['url1']:'images/lg.jpg').'" width="150">
  14.  
  15. </td>
  16.  
  17. <td width="450">
  18. <p class="nazwaobiektu2"><a href="?do=edit&o='.$wiersz['id'].'">
  19. '.$wiersz['nazwa'].'</a></p><br>
  20. <p class="cenywwynikach">Cena od: <b class="b3">
  21.  
  22. <p class="miescwoj">miesjcowosc: <b class="b2">'.$wiersz['miasto'].'</b>, woj.<b class="b2">';
  23. $q="SELECT * FROM `wojewodztwa` WHERE id='$wiersz[woj]'";
  24. $r=mysql_query($q); 
  25. while ($w= mysql_fetch_array($r))
  26. {
  27. echo $w['nazwa'];
  28. }
  29. echo '</b></p></p>
  30.  
  31. </td>
  32. <td width="50">
  33.  
  34. </td>
  35. </tr>
  36.  
  37. </table>
  38. </td>
  39. </tr>
  40. </table><br><br style="line-height:7px" />';
  41. $tablica[0]=$wiersz['id'];
  42. }
  43. }
  44. }
  45. ?>


jak zauwazyliscie przy nazwie wpisu jest link
  1. "<a href="?do=edit&o='.$wiersz['id'].'">
  2. '.$wiersz['nazwa'].'</a>


i wlasnie ten link idzie do tego kodu:
  1. <?php
  2. else if($_GET['do'] == 'edit')
  3. {
  4.  
  5.  
  6. $title = 'Zmien swój opis obiektu noclegowego';
  7. $con = "<div id='witaj'><h2>Personal Settings</h2>
  8. Nazwa: <span id='nazwa'>{$wiersz['nazwa']}</span><br />
  9. E-Mail: <span id='email'>{$wiersz['email']}</span>
  10. <script type='text/javascript'>
  11.  new Ajax.InPlaceEditor('nazwa', 'ajax.php?m=optsavee&type=nazwa&id={$obiekt['id']}');
  12. new Ajax.InPlaceEditor('email', 'ajax.php?m=optsavee&type=email&id={$obiekt['id']}');
  13. </script>
  14. <h2>Password Control</h2>
  15. <p>In order to edit your password, you must first verify your current one, then 
    enter your new one:</p>
  16. <form name='password_reset'>
  17. Current Password: <input type='password' id='current_password' /><br />
  18. New Password: <input type='password' id='new_password' /><br />
  19. Confirm New Password: <input type='password' id='new_password_confirm' /><br />
  20. <input type='button' value='change password' onclick='password()' id='change_password' /></form></div>
  21. <div id='password_status'></div>";
  22. }
  23. ?>

i tu jest moj problem. Zamiast pobrac nazwe i email z tabeli obiekty to on to robi z tabeli user.
Dlatego sprawdzilem plik ajax.php
oto on:
  1. <?php
  2. //Load up database, functions, user info
  3. include('./config.php');
  4.  
  5. if(@$_POST['m'] == 'login')
  6. {
  7. if(login($_POST['username'], md5($_POST['password'])))
  8. { //success
  9. echo "1";
  10. }
  11. else
  12. { //failure hmph
  13. echo "0";
  14. }
  15. }
  16. //in place editor is GET
  17. else if(@$_GET['m'] == 'optsave')
  18. {
  19. if($_GET['type'] == 'email')
  20. {
  21. edit_email($_POST['value'], $_GET['id']);
  22. }
  23. else
  24. {
  25. edit_name($_POST['value'], $_GET['id']);
  26. }
  27. //AJAX will update field to this value
  28. echo $_POST['value'];
  29. }
  30. //in place editor is GET
  31. else if(@$_GET['m'] == 'optsavee')
  32. {
  33. if($_GET['type'] == 'email')
  34. {
  35. edit_email($_POST['value'], $_GET['id']);
  36. }
  37. else
  38. {
  39. edit_nazwa($_POST['value'], $_GET['id']);
  40. }
  41. //AJAX will update field to this value
  42. echo $_POST['value'];
  43. }
  44. else if($_POST['m'] == 'pwd')
  45. {
  46. if(md5($_POST['current']) == $user['password'])
  47. {
  48. if(edit_password(md5($_POST['new']), $_POST['id']))
  49. { //success
  50. echo "Thanks, your password has been updated!";
  51. }
  52. else
  53. { //hmm
  54. echo "An error occured when changing your password, please try again.";
  55. }
  56. }
  57. else
  58. { //little shady :)
  59. echo "The password you provided does not match your current password, please try 
    again."
    ;
  60. }
  61. }
  62. else if($_POST['m'] == 'check')
  63. {
  64. //Checks username/email in the DB
  65. if(is_taken($_POST['type'], $_POST['value']))
  66. { //sucess
  67. echo "0";
  68. }
  69. else
  70. { //failure
  71. echo "1";
  72. }
  73. }
  74.  
  75. else if($_POST['m'] == 'deluser')
  76. {
  77. if($user['password'] == $_POST['password'] && $user['admin'] == '2')
  78. {
  79. if(delete_user($_POST['id']))
  80. { //sucess
  81. echo "1";
  82. }
  83. else
  84. { //failure
  85. echo "0";
  86. }
  87. }
  88. }
  89.  
  90. //Edit users
  91. else if($_POST['m'] == 'edituser')
  92. {
  93. //Ensure user is admin
  94. if($user['password'] == $_POST['password'] && $user['admin'] == '2')
  95. {
  96. if(edit_user($_POST['id'], $_POST['username'], $_POST['name'], $_POST['email'], $_POST['auth']))
  97. { //sucess
  98. echo "1";
  99. }
  100. else
  101. { //failure
  102. echo "0";
  103. }
  104. }
  105. }
  106. //Edit obiekty
  107. else if($_POST['m'] == 'editobiekt')
  108. {
  109. //Ensure user is admin
  110. if($user['password'] == $_POST['password'] && $user['admin'] == '2')
  111. {
  112. if(edit_obiekt($_POST['id'], $_POST['nazwa'], $_POST['ul'], $_POST['email'], $_POST['kod']))
  113. { //sucess
  114. echo "1";
  115. }
  116. else
  117. { //failure
  118. echo "0";
  119. }
  120. }
  121. }
  122. ?>

a oto jeszcze jeden plik "members" w ktorym jak zauwazylem sa pobierane lub zapisywane dane w tabelach. i tu chyba (tak ja uwazam) trzeba cos zrobic.
  1. <?php
  2.  
  3. //Checks if a given field in the users table is taken
  4. function is_taken($field, $value)
  5. {
  6. $query = mysql_query("SELECT `id` FROM `users` WHERE `$field` = '$value'");
  7. if(mysql_num_rows($query) > 0)
  8. {
  9. return true;
  10. }
  11. else
  12. {
  13. return false;
  14. }
  15. }
  16.  
  17. //Checks login details
  18. function check_login($username, $password)
  19. {
  20. $query = mysql_query("SELECT `id` FROM `users` WHERE `username` = '$username' AND `password` = '$password'") or die(mysql_error());
  21. if(mysql_num_rows($query) > 0)
  22. {
  23. return true;
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29. }
  30.  
  31. //Updates a users details in the database
  32. function edit_user($id, $username, $name, $email, $admin)
  33. {
  34. $query = mysql_query("UPDATE `users` SET `username` = '$username', `name` = '$name', `email` = '$email', `admin` = '$admin' WHERE `id` = '$id'");
  35. if($query)
  36. {
  37. return true;
  38. }
  39. else
  40. {
  41. return false;
  42. }
  43. }
  44. //Updates a obiekt details in the database
  45. function edit_obiekt($id, $nazwa, $ul, $email, $kod)
  46. {
  47. $query = mysql_query("UPDATE `obiekty` SET `nazwa` = '$nazwa', `ul` = '$ul', `email` = '$email', `kod` = '$kod' WHERE `id` = '$o'");
  48. if($query)
  49. {
  50. return true;
  51. }
  52. else
  53. {
  54. return false;
  55. }
  56. }
  57.  
  58. //Remove user from database
  59. function delete_user($id)
  60. {
  61. $query = mysql_query("DELETE FROM `users` WHERE `id` = '$id'");
  62. if($query)
  63. {
  64. return true;
  65. }
  66. else
  67. {
  68. return false;
  69. }
  70. }
  71.  
  72. //Gets an array of all user data from the database
  73. function userdata($id, $pass)
  74. {
  75. if(!check_login($id, $pass))
  76. {
  77. //Fill array with guest data
  78. $user = array('id' => '0', 'username' => 'Guest', 'password' => '', 'name' => 'Guest', 'email' => '', 'ip' => $_SERVER['REMOTE_ADDR'], 'admin' => '0');
  79. }
  80. else
  81. {
  82. $query = mysql_query("SELECT `username`, `password`, `name`, `email`, `ip`, `admin`, `id` FROM `u
    sers` WHERE `username` = '$id'"
    );
  83. $r = mysql_fetch_row($query);
  84. $user = array('id' => $r[6], 'username' => $r[0], 'password' => $r[1], 'name' => $r[2], 'email' => $r[3], 'ip' => $r[4], 'admin' => $r[5]);
  85. }
  86. return $user;
  87. }
  88.  
  89. // Edit only the name (AJAX)
  90. function edit_name($name, $id)
  91. {
  92. $query = mysql_query("UPDATE `users` SET `name` = '$name' WHERE `id` = '$id'");
  93. return true;
  94. }
  95.  
  96. //Edit only the E-Mail (AJAX)
  97. function edit_email($email, $id)
  98. {
  99. $query = mysql_query("UPDATE `users` SET `email` = '$email' WHERE `id` = '$id'");
  100. return true;
  101. }
  102.  
  103. //Edit only the password (AJAX)
  104. function edit_password($password, $id)
  105. {
  106. //check hash
  107. if(strlen($password) !== 32)
  108. {
  109. $password = md5($password);
  110. }
  111. $query = mysql_query("UPDATE `users` SET `password` = '$password' WHERE `id` = '$id'");
  112. if($query)
  113. {
  114. $_SESSION['password'] = $password;
  115. $_COOKIE['password'] = $password;
  116. return true;
  117. }
  118. else
  119. {
  120. return false;
  121. }
  122. }
  123. //end AJAX specific functions
  124.  
  125. //Generates key x long, md5's it
  126. function generate_key($length)
  127. {
  128. return(md5(substr(str_shuffle('qwertyuiopasdfghjklmnbvcxz0987612345'), 0, $length)));
  129. }
  130.  
  131.  
  132. //Get a count of the entries in a given table 
  133. function count_tbl($tbl)
  134. {
  135. $query = mysql_query("SELECT COUNT(*) FROM `$tbl`");
  136. $r = mysql_fetch_row($query);
  137. return $r[0];
  138. }
  139. ?>

mozecie mi doradzic co tu musze dolozyc?