Answer the question
In order to leave comments, you need to log in
Transferring a variable from one file to another?
Good afternoon, here is such a thing, I need to throw the id parameter from one file into another in order to edit the vacancy on it.
the page where the button is located, and this variable is formed
<?php
$Param1 = 'SELECT `id`, `title`, `regdate` FROM vacancies ORDER BY `id` DESC LIMIT 0, 10' ;
$Query = mysqli_query($CONNECT, $Param1);
while ($Row = mysqli_fetch_assoc($Query))
{
echo
'
<br>
<div class="titlevac">
<br>
<h2>'.$Row['title'].'</h2>
<br>
<span>ID новости: '.$Row['id'].'</span>
<a href="/admin/editvacancies?id='.$Row['id'].'">Edit</a> | <a href="requesthandlerdeletevacancies?id='.$Row['id'].'">Delete</a>
<br>
<span>Дата добавления: '.$Row['regdate'].'</span><br><br><hr>
</div>
';
}
?>
<div class="edit">
<form method="POST" action="requesthandlereditvacancies">
<script type="text/javascript">
window.onload = function()
{
CKEDITOR.replace('preview');
CKEDITOR.replace('content');
};
</script>
<br>
<input type = "text" name = "title" placeholder = "Введите новое название вакансии" required autocomplete="off"><br><br>
ID вакансии: <textarea name = "id"></textarea><br>
Краткое описание вакансии: <textarea name = "preview"></textarea><br>
Полное описание вакансии: <textarea name = "content"></textarea><br>
<input type = "submit" name = "enter" value = "Изменить вакансию"> <input type = "reset" value = "Очистить поля">
</form>
</div>
<?php
if($Module == 'requesthandlereditvacancies' and $_POST['enter'])
{
$_POST['title'] = FormChars($_POST['title']);
$_POST['preview'] = FormChars($_POST['preview']);
$_POST['content'] = FormChars($_POST['content']);
if(!$_POST['title'] or !$_POST['preview'] or !$_POST['content'])
{
MessageSend(1,'Ошибка валидации формы.');
}
else
{
mysqli_query($CONNECT, "UPDATE `vacancies` SET title = '$_POST[title]', preview = '$_POST[preview]', content = '$_POST[content]', regdate = NOW() WHERE id=$_POST[id]");
MessageSend(3,'Данные изменены в базе данных.');
}
}
?>
Answer the question
In order to leave comments, you need to log in
Where we form an array
<?php
$Param1 = 'SELECT `id`, `title`, `regdate` FROM vacancies ORDER BY `id` DESC LIMIT 0, 5' ;
$Query = mysqli_query($CONNECT, $Param1);
while ($Row = mysqli_fetch_assoc($Query))
{
echo
'
<br>
<div class="titlevac">
<br>
<h2>'.$Row['title'].'</h2>
<br>
<span>ID новости: '.$Row['id'].'</span>
<a href="/admin/editvacancies?id='.$Row['id'].'">Edit</a> | <a href="requesthandlerdeletevacancies?id='.$Row['id'].'">Delete</a>
<br>
<span>Дата добавления: '.$Row['regdate'].'</span><br><br><hr>
</div>
';
}
?>
<form method="POST" action="requesthandlereditvacancies">
<script type="text/javascript">
window.onload = function()
{
CKEDITOR.replace('preview');
CKEDITOR.replace('content');
};
</script>
<br>
<?php $id=$_GET["id"];?>
<input type = "text" name = "title" placeholder = "Введите новое название вакансии" required autocomplete="off"><br><br>
ID вакансии: <textarea name = "id" readonly><?php echo $id; ?></textarea><br>
Краткое описание вакансии: <textarea name = "preview"></textarea><br>
Полное описание вакансии: <textarea name = "content"></textarea><br>
<input type = "submit" name = "enter" value = "Изменить вакансию"> <input type = "reset" value = "Очистить поля">
</form>
<?php
if($Module == 'requesthandlereditvacancies' and $_POST['enter'])
{
$_POST['title'] = FormChars($_POST['title']);
$_POST['preview'] = FormChars($_POST['preview']);
$_POST['content'] = FormChars($_POST['content']);
if(!$_POST['title'] or !$_POST['preview'] or !$_POST['content'])
{
MessageSend(1,'Ошибка валидации формы.');
}
else
{
mysqli_query($CONNECT, "UPDATE `vacancies` SET title = '$_POST[title]', preview = '$_POST[preview]', content = '$_POST[content]', regdate = NOW() WHERE id=$_POST[id]");
MessageSend(3,'Данные изменены в базе данных.');
}
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question