<?php
include_once "bd.php";
require_once "edit_advertisement.php";
if (isset($_POST['clic1'])) {
$square = $_POST['square'];
$square = stripslashes($square);
$square = htmlspecialchars($square);
$title = $_POST['title'];
$title = stripslashes($title);
$title = htmlspecialchars($title);
$text = $_POST['text'];
$text = stripslashes($text);
$text = htmlspecialchars($text);
$adress = $_POST['adress'];
$adress = stripslashes($adress);
$adress = htmlspecialchars($adress);
$price = $_POST['price'];
$price = stripslashes($price);
$price = htmlspecialchars($price);
$name_user = $_POST['name_user'];
$name_user = stripslashes($name_user);
$name_user = htmlspecialchars($name_user);
$telephone = $_POST['telephone'];
$telephone = stripslashes($telephone);
$telephone = htmlspecialchars($telephone);
$skype = $_POST['skype'];
$skype = stripslashes($skype);
$skype = htmlspecialchars($skype);
$icq = $_POST['icq'];
$icq = stripslashes($icq);
$icq = htmlspecialchars($icq);
$query = ("UPDATE advertisement
SET square='$square', title='$title', text='$text', adress='$adress', price='$price', name_user='$name_user', telephone='$telephone', skype='$skype', icq='$icq' WHERE id='$id'");
$result = mysql_query($query) or die(mysql_error());
echo '<font color="green"><img border="0" src="ok.gif" alt="Ви успішно редагували об\'яву!">Ви успішно редагували об\'яву!</font><br><a href="index.php">На головну</a>';
}
?>
А это код самой страницы редактирования объявления:
<?php
include_once "bd.php";
require_once "function_edit_advertisement.php";
if (isset($_GET['id'])){
//То заносимо значення id_user
$id = (int)$_GET['id'];
$resultat = mysql_query ("SELECT * FROM `advertisement` WHERE id = '$id'");
$res = mysql_fetch_assoc($resultat);
}
?>
<body>
<?php
if($res['id_user']==$id_user) {
echo ' <form name="reg" action="function_edit_advertisement.php" method="post" enctype="multipart/form-data">
<center><h3>Редагувати об\'яву</h3>
<input type=hidden name=razdelname value="">
<input type=hidden name=podrazdelname value="">
<input type=hidden name=file1 value="">
<table width=900px align=center><tr><td>
<table class="price" width=900px >
<tr bgcolor=#FFFFFF><td align=right>Площа, кв.м.:</td>
<td><input type=text name="square" class="minput" maxlength="10" value="'.$res[square].'"></td></tr>
<tr bgcolor=#FFFFFF><td align=right valign=top>Назва об\'яви:</td>
<td><input type=text name="title" class=input value="'.$res[title].'"><br><small>до 50 символів</small></td></tr>
<tr bgcolor=#FFFFFF><td align=right valign=top>
<div class="textc">
<p>Текст об\'яви</p>
<center><textarea rows=15 cols=43 id="elm1" name="text">'.$res[text].'</textarea>
</div>
</td></tr>
<tr bgcolor=#FFFFFF><td align=right valign=top>Адрес:</td>
<td><input type=text name="adress" class=input value="'.$res[adress].'"><br><small><font color=#FF0000>*</font>Вулиця, будинок.</small></td></tr>
<tr bgcolor=#FFFFFF><td align=right>Ціна:</td>
<td><input type=text name="price" class=sinput value="'.$res[price].'"><br><small>Ціле число, <b>тільки в грн</b></small></td></tr>
<tr bgcolor=#FFFFFF><td align=right>Ім\'я:</td>
<td><input type=text name="name_user" class=sinput value="'.$res[name_user].'"></td></tr>
<tr bgcolor=#FFFFFF><td align=right>Телефон:</td>
<td><input type=text name="telephone" class=sinput value="'.$res[telephone].'"></td></tr>
<tr bgcolor=#FFFFFF><td align=right>Skype:</td>
<td><input type=text name="skype" size=30 class=sinput value="'.$res[skype].'"></td></tr>
<tr bgcolor=#FFFFFF><td align=right>ICQ:</td>
<td><input type=text name="icq" size=30 class=sinput value="'.$res[icq].'"></td></tr>
</table></td></tr></table>
<center><p><input type=submit value="Редагувати" name="clic1" class=button>
</div>
</form> ';
}
else {
echo "Ви не можете редактувати це оголошення <a href='index.php'>На головну</a>";
}
?>
</body>
Мне выводит "Ви не можете редактувати це оголошення На головну Ви успішно редагували об'яву!
На головну".
Это наверное из-за этого подключения
require_once "edit_advertisement.php";
Потому что в обработчике id пользователя не считывается
Что мне сделать?????