0

i'm having a problem with parsing variables from previous page and saving to database on the next page. i have two pages .
first page is where i view my data. i do a select sum, and it works.

now on my second page i want to take the total of the sum and save to database but

this is what i see when i echo my $sql query on my second page

"insert into admit (dated,valued) values (,) " which means my values are not taken in.

first page

admission.php

?php
require_once('Connect.php');

          echo'<table>';
          echo'<tbody> '; 

 $sql2="select sum(valued) as totalvalue from details where marker='' and dated='$dated'";
         $query = mysqli_query($conn,$sql2);
         $row2 = mysqli_fetch_array($query);


       echo '<tr>
            <td> TOTAL VALUE FOR &nbsp;'.$dated.'</TD>
            <td>' . $row2['totalvalue'] . '</td>
            </tr>';

            echo'<tr><td><a href="confirm admission.php?date=' . $dated . '+'.$row2['totalvalue'].'">admit value</a></td></tr>'; 

        echo'</tbody> ';  
          echo'</table>';



          ?> 

second page

confirm admission.php

<?php
require_once('Connect.php');

      $dated=$_REQUEST['dated'];
     $valued = $_REQUEST['valued']; 


if (isset($_REQUEST['admit']))    
      {    

    $sql="insert into admit (dated,valued) values ($dated,$valued) ";
    mysqli_query($conn,$sql);

    echo $sql;

      }
?>
<html>
<head>

</head>
  <body>
          <form name="form" method="GET" >

              are you sure you want to admit <?php echo $dated ?> <br /><br />

        <input type="submit" name="admit" value="yes">

        <a href="admission.php">no</img></a>


              </form>
              </td>

</body>
</html>
2
Contributors
1
Reply
14
Views
2 Years
Discussion Span
Last Post by milil
1

You can set your value you want in session and then just in secound page get that value from session.

on first page:
$_SESSION['value']= "Anything you want!";

on second page:
$variable = "";
if(isset($_SESSION['value'])) {
    $variable = $_SESSION["value"];
}

and if you work with sessions you need to put this on begining of php tag.
session_start();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.