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:
<?php { if ($wiersz['id']!=$tablica[0]) { echo '<table width="600" align="center"> <tr> <td width="600" height="170"><br><br style="line-height:10px" /><center> <table width="600" height="170" border=1 bordercolor=darkgray cellspacing="2" cellpadding="5" rules=none> <tr> <td width="100" rowspan=8 width="5" valign="middle" cellspacing="2"> <img class="obiekt" src="'.(($wiersz['url1'])?$wiersz['url1']:'images/lg.jpg').'" width="150"> </td> <td width="450"> <p class="nazwaobiektu2"><a href="?do=edit&o='.$wiersz['id'].'"> '.$wiersz['nazwa'].'</a></p><br> <p class="cenywwynikach">Cena od: <b class="b3"> <p class="miescwoj">miesjcowosc: <b class="b2">'.$wiersz['miasto'].'</b>, woj.<b class="b2">'; $q="SELECT * FROM `wojewodztwa` WHERE id='$wiersz[woj]'"; { } echo '</b></p></p> </td> <td width="50"> </td> </tr> </table> </td> </tr> </table><br><br style="line-height:7px" />'; $tablica[0]=$wiersz['id']; } } } ?>
jak zauwazyliscie przy nazwie wpisu jest link
i wlasnie ten link idzie do tego kodu:
<?php else if($_GET['do'] == 'edit') { $title = 'Zmien swój opis obiektu noclegowego'; $con = "<div id='witaj'><h2>Personal Settings</h2> Nazwa: <span id='nazwa'>{$wiersz['nazwa']}</span><br /> E-Mail: <span id='email'>{$wiersz['email']}</span> <script type='text/javascript'> new Ajax.InPlaceEditor('nazwa', 'ajax.php?m=optsavee&type=nazwa&id={$obiekt['id']}'); new Ajax.InPlaceEditor('email', 'ajax.php?m=optsavee&type=email&id={$obiekt['id']}'); </script> <h2>Password Control</h2> <p>In order to edit your password, you must first verify your current one, then
enter your new one:</p> <form name='password_reset'> Current Password: <input type='password' id='current_password' /><br /> New Password: <input type='password' id='new_password' /><br /> Confirm New Password: <input type='password' id='new_password_confirm' /><br /> <input type='button' value='change password' onclick='password()' id='change_password' /></form></div> <div id='password_status'></div>"; } ?>
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:
<?php //Load up database, functions, user info include('./config.php'); if(@$_POST['m'] == 'login') { { //success } else { //failure hmph } } //in place editor is GET else if(@$_GET['m'] == 'optsave') { if($_GET['type'] == 'email') { edit_email($_POST['value'], $_GET['id']); } else { edit_name($_POST['value'], $_GET['id']); } //AJAX will update field to this value } //in place editor is GET else if(@$_GET['m'] == 'optsavee') { if($_GET['type'] == 'email') { edit_email($_POST['value'], $_GET['id']); } else { edit_nazwa($_POST['value'], $_GET['id']); } //AJAX will update field to this value } else if($_POST['m'] == 'pwd') { { { //success } else { //hmm } } else { //little shady :) } } else if($_POST['m'] == 'check') { //Checks username/email in the DB if(is_taken($_POST['type'], $_POST['value'])) { //sucess } else { //failure } } else if($_POST['m'] == 'deluser') { if($user['password'] == $_POST['password'] && $user['admin'] == '2') { if(delete_user($_POST['id'])) { //sucess } else { //failure } } } //Edit users else if($_POST['m'] == 'edituser') { //Ensure user is admin if($user['password'] == $_POST['password'] && $user['admin'] == '2') { if(edit_user($_POST['id'], $_POST['username'], $_POST['name'], $_POST['email'], $_POST['auth'])) { //sucess } else { //failure } } } //Edit obiekty else if($_POST['m'] == 'editobiekt') { //Ensure user is admin if($user['password'] == $_POST['password'] && $user['admin'] == '2') { if(edit_obiekt($_POST['id'], $_POST['nazwa'], $_POST['ul'], $_POST['email'], $_POST['kod'])) { //sucess } else { //failure } } } ?>
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.
<?php //Checks if a given field in the users table is taken function is_taken($field, $value) { { return true; } else { return false; } } //Checks login details function check_login($username, $password) { $query = mysql_query("SELECT `id` FROM `users` WHERE `username` = '$username' AND `password` = '$password'") or die(mysql_error()); { return true; } else { return false; } } //Updates a users details in the database function edit_user($id, $username, $name, $email, $admin) { $query = mysql_query("UPDATE `users` SET `username` = '$username', `name` = '$name', `email` = '$email', `admin` = '$admin' WHERE `id` = '$id'"); if($query) { return true; } else { return false; } } //Updates a obiekt details in the database function edit_obiekt($id, $nazwa, $ul, $email, $kod) { $query = mysql_query("UPDATE `obiekty` SET `nazwa` = '$nazwa', `ul` = '$ul', `email` = '$email', `kod` = '$kod' WHERE `id` = '$o'"); if($query) { return true; } else { return false; } } //Remove user from database function delete_user($id) { if($query) { return true; } else { return false; } } //Gets an array of all user data from the database function userdata($id, $pass) { if(!check_login($id, $pass)) { //Fill array with guest data $user = array('id' => '0', 'username' => 'Guest', 'password' => '', 'name' => 'Guest', 'email' => '', 'ip' => $_SERVER['REMOTE_ADDR'], 'admin' => '0'); } else { $query = mysql_query("SELECT `username`, `password`, `name`, `email`, `ip`, `admin`, `id` FROM `u
sers` WHERE `username` = '$id'"); $user = array('id' => $r[6], 'username' => $r[0], 'password' => $r[1], 'name' => $r[2], 'email' => $r[3], 'ip' => $r[4], 'admin' => $r[5]); } return $user; } // Edit only the name (AJAX) function edit_name($name, $id) { return true; } //Edit only the E-Mail (AJAX) function edit_email($email, $id) { return true; } //Edit only the password (AJAX) function edit_password($password, $id) { //check hash { } if($query) { $_SESSION['password'] = $password; $_COOKIE['password'] = $password; return true; } else { return false; } } //end AJAX specific functions //Generates key x long, md5's it function generate_key($length) { } //Get a count of the entries in a given table function count_tbl($tbl) { return $r[0]; } ?>
mozecie mi doradzic co tu musze dolozyc?