@Rasul_El-Sheikh

Как получить заполненные автоматические данные?

Приветствую. Как данные из этой формы
<?php
  session_start();
  require_once('db.php');
  
  date_default_timezone_set('Asia/Almaty' );
  
  if(isset($_POST['update'])){
    header ("Location: admin_update.php");
  }
?>
<html>
    <head>
        <link href="css/style.css" type="text/css" rel="stylesheet">
        <title></title>
    </head>
    <body>
      <section class="tabs">
	<input id="tab_1" type="radio" name="tab" checked="checked" />
	<input id="tab_2" type="radio" name="tab" />
	<input id="tab_3" type="radio" name="tab" />
	
	<label for="tab_1" id="tab_l1">Today orders</label>
	<label for="tab_2" id="tab_l2">Past orders</label>
	<label for="tab_3" id="tab_l3">Future orders</label>
	<div style="clear:both"></div>

	<div class="tabs_cont">
		<div id="tab_c1"><?
     $current_day = date("d");
     $current_month = date("m");
     $select_flight_user = "SELECT * FROM current_flight WHERE goday = '{$current_day}' && gomonth = '{$current_month}'";
     $query = mysqli_query($db_connect, $select_flight_user);
     $count_rows = mysqli_num_rows($query);
      if($count_rows == 0){
         echo "Today no orders";
     } else {
        while($flight = mysqli_fetch_assoc($query)){
         if(isset($flight)){?>
         <form name="up_del" action="" method="POST">
            <table>
             <tr>
            <td>Login:<? echo $flight['id_user'];
                         $_SESSION['id_user'] = $flight['id_user']; ?></td>
            &nbsp;
            <td>Flight:<? echo $flight['gocity']; ?></td>
            &nbsp;
            <td>Date:<? echo $flight['godate'];?></td>
            &nbsp;
            <td>Action:</td>
        </tr>
        <tr>
            <td>Mobile:</td>
            &nbsp;
            <td>Sum passengers:</td>
            &nbsp;
            <td>Time:</td>
            <td><button name="update">Update</button></td>
            <td>Delete</td>
        </tr>
        <tr>
            <td>Condition:</td>
            &nbsp;
            <td>Amount:</td>
        </tr>
        </table>
         </form>
           <? }   
            } 
            }
     ?>
                </div>
		<div id="tab_c2"> <?
     $current_month = date("m");
     $select_flight_user = "SELECT * FROM current_flight WHERE gomonth < '{$current_month}'";
     $query = mysqli_query($db_connect, $select_flight_user);
     $count_rows = mysqli_num_rows($query);
      if($count_rows == 0){
         echo "Past no orders";
     } else {
        while($flight = mysqli_fetch_assoc($query)){
         if(isset($flight)){?>
         <form name="up_del" action="" method="POST">
            <table>
             <tr>
            <td>Login:<? echo $flight['id_user'];
                         $_SESSION[''] = $flight['id_user'];?></td>
            &nbsp;
            <td>Flight:<? echo $flight['gocity'];?></td>
            &nbsp;
            <td>Date:<? echo $flight['godate'];?></td>
            &nbsp;
            <td>Action:</td>
        </tr>
        <tr>
            <td>Mobile:</td>
            &nbsp;
            <td>Sum passengers:</td>
            &nbsp;
            <td>Time:</td>
            <td><button name="update">Update</button></td>
            <td>Delete</td>
        </tr>
        <tr>
            <td>Condition:</td>
            &nbsp;
            <td>Amount:</td>
        </tr>
        </table>
         </form>
           <? }   
            } 
            }
     ?>
     </div>
		<div id="tab_c3">
                    <?
     $current_month = date("m");
     $select_flight_user = "SELECT * FROM current_flight WHERE gomonth > '{$current_month}'";
     $query = mysqli_query($db_connect, $select_flight_user);
     $count_rows = mysqli_num_rows($query);
      if($count_rows == 0){
         echo "Future No orders";
     } else {
        while($flight = mysqli_fetch_assoc($query)){
         if(isset($flight)){?>
         <form name="up_del" action="" method="POST">
            <table>
             <tr>
            <td>Login:<? echo $flight['id_user'];
                         $_SESSION['id_user'] = $flight['id_user']?></td>
            &nbsp;
            <td>Flight:<? echo $flight['gocity'];?></td>
            &nbsp;
            <td>Date:<? echo $flight['godate'];?></td>
            &nbsp;
            <td>Action:</td>
        </tr>
        <tr>
            <td>Mobile:</td>
            &nbsp;
            <td>Sum passengers:</td>
            &nbsp;
            <td>Time:</td>
            <td><button name="update">Update</button></td>
            <td>Delete</td>
        </tr>
        <tr>
            <td>Condition:</td>
            &nbsp;
            <td>Amount:</td>
        </tr>
        </table>
            </form>
           <? }   
            } 
            }
     ?>
                </div>
	</div>
</section>
    </body>
    <footer>
        
    </footer>
</html>
получить автоматически в этой
<?php
  session_start();
  require_once('db.php');
  
  $gocity = $_POST['gocity'];
  $id_user = $_SESSION['id_user'];
  $current_month = date("m");
  if(isset($_POST['ready'])){
    $update_order = "UPDATE `current_flight` SET `gocity` = '".$gocity."' WHERE `id_user` = '".$id_user."'
                     AND `gomonth` > '".$current_month."' ";
    $query = mysqli_query($db_connect, $update_order) or die("Error");                 
    $count_row = mysqli_affected_rows($db_connect);
    if($count_row == 0){
      echo "Update failed";
    } else {
      header ("Location: admin.php");
      echo "Update succeeded";
    }
  }
?>
  <form action="" method="POST">
  <table>
       <tr>
      <td>Login:<? echo $_SESSION['id_user']; ?></td>
      &nbsp;
      <td>Flight:<input type="text" name="gocity" value="<? ; ?>" /></td>
      &nbsp;
      <td>Date:<? echo $flight['godate'];?></td>
      &nbsp;
      <td>Action:</td>
  </tr>
  <tr>
      <td>Mobile:</td>
      &nbsp;
      <td>Sum passengers:</td>
      &nbsp;
      <td>Time:</td>
      <td><button name="ready">Ready</button></td>
      <td>Delete</td>
  </tr>
  <tr>
      <td>Condition:</td>
      &nbsp;
      <td>Amount:</td>
  </tr>
  </table>
  </form>
. Мне нужно, чтобы в зависимости от того на какую кнопку я нажал (Update в первом документе), данные привязанные к ней заносились в эту строку Flight: (второго документа).

Пост-скриптум: да, код страшный, да, вопрос плевый для опытного разработчика.
  • Вопрос задан
  • 181 просмотр
Пригласить эксперта
Ответы на вопрос 1
He11ion
@He11ion
PHP-monkey
Писать, скажем, в сессию, а во втором файле вставлять в input в value. Сохранять значения как угодно - через сабмит формы/аяксом/средствами браузера.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы