Hi guys, I have a problem with my form - it is stop working when I add new button “transwer”
My database have four tables:
main table - “dziennik1” and 3 offices - office1, office2, office3
I was thinnkig that i found a solution here becouse is a similar subject but when I read post I am think that case is totally diferent.
So everythink works fine until i have to add “transfer” button. It is stop and I do not know why - this is the first problem
second is more difficult - I don’t konow how to create to selection to transfer record from main table to the tabel office1 or office2, or office3 when I my choice will be on the website table (status)
Sorry for my english I am not a english person
best regards
Przemek
the file with form look like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>WORKS</title>
</head>
<body>
<a href="index.php">WorksToDo</a>
<a href="indexWykonane.php">WorksDone</a>
<a href="indexSzukaj.php">Works serch</a>
<a href="office1.php">Office1</a>
<a href="office2.php">Office2</a>
<a href="office3.php">Office3</a>
<h1>Works Done</h1>
<table border="1">
<tr>
<th>Id</th>
<th>Name</th>
<th>User</th>
<th>Status</th>
<th>Data incomming</th>
<th>Change</th>
<th>Delete</th>
<th>Move</th>
</tr>
<?//if($facts) foreach($facts as $z):?>
<?foreach($show as $z):?>
<tr>
<form action="usunZadanie.php" method="post">
<td><?=$z['id']?></td>
<td><input type='text' value='<?=$z['nazwa']?>' name="nazwa"></td>
<td><input type='text' value='<?=$z['user1']?>' name="user1"></td>
<td><select name="office" '<?=$z['office']?>' </td>" >
<option><?=$z['office']?></option>
<option >Office1</option>
<option>Office2</option>
<option>Office3</option>
</select>
<td><?=$z['data_wprowadzenia']?></td>
<td>
<input type="hidden" name="id" value="<?=$z['id']?>">
<input type="hidden" name="action" value="change">
<input type="submit" value="Change">
</td>
</form>
<td>
<form action="usunZadanie.php" method="post">
<input type="hidden" name="id" value="<?=$z['id']?>">
<input type="hidden" name="action" value="delete">
<input type="submit" value="Delete">
</form>
</td>
<td>
<form action="usunZadanie.php" method="post">
<input type="hidden" name="id" value="<?=$z['id']?>">
<input type="hidden" name="tranfer" value="transfer">
<input type="submit" value="Transfer">
</form>
</td>
</tr>
<?endforeach;?>
</table>
</body>
</html>
and PHP file
<?php
include 'common.php';
if(isset($_REQUEST['id']) && isset($_REQUEST['action']) && isset($_REQUEST['transfer'])){
$id = (int)$_REQUEST['id'];
$action = $_REQUEST['action'];
$transfer = $_REQUEST['transfer'];
$query = false;
if ($action == 'change'){
if(isset($_REQUEST['nazwa'])){
$nazwa = pg_escape_string($_REQUEST['nazwa']);
$user1 = pg_escape_string($_REQUEST['user1']);
$office = pg_escape_string($_REQUEST['office']);
$query = "UPDATE dziennik1 SET nazwa='$nazwa', user1='$user1', office='$office' WHERE id=$id";
}
} else if ($action == 'delete'){
$query = "DELETE FROM dziennik1 WHERE id=$id";
} else if ($transfer == 'transfer'){
$query = "INSERT INTO office (nazwa, user1) SELECT nazwa, user1 FROM dziennik1 WHERE id=$id";
}
if($query){
pg_query($query);
}
}
header('Location:indexWykonane.php');