Hello,

I am having a company here with foreign retailing. I have to ship packages abroad. Due to workload I cannot remember what parcels I have sent.

I had a script which I used to print Labels to print. But now, what I want is, while the script prints a styled preview of what is entered in previous page, it also get saved in Database (MYSQL)

Before, I do not save it anywhere, I just enter the data in inv.php and push shubmit and it shows a preview, which I have customised on the other page. But now I want, that on the preview.php page it also get entered in a MySql Databse. is it possible?

Here are two scripts I am using
INV.php

<style type="text/css">
<!--
.cap {
 text-transform: uppercase;
}
-->
</style>
<form method="POST" action="preview.php">
<div align="center"></div>
<table width="100%">
  <tr>
    <td width="9%" class="K">TO:</td>
    <td width="26%" align="justify"><textarea name="to" cols="50" rows="5" class="cap" id="to" ></textarea></td>
    <td align="center" width="6%" class="K"> FROM:</td>
    <td width="59%" class="K" align="justify"><textarea name="from" cols="50" rows="5" id="from">My address</textarea></td>
  </tr>
  <tr>
    <td class="K"><p>&nbsp;</p></td>
    <td>&nbsp;</td>
    <td align="center" class="K">&nbsp;</td>
    <td class="K">&nbsp;</td>
  </tr>
  <tr>
    <td class="K">Category:</td>
    <td><input name="cat" type="text" class="K" id="cat" size="50" /></td>
    <td align="center" class="K">Weight:</td>
    <td class="K"><input name="wgt" type="text" class="K" id="wgt" />
      Grams</td>
  </tr>
  <tr>
    <td height="61" class="K">Value of Contents:</td>
    <td><input name="usd" type="text" class="K" id="usd" /> 
      <span class="K">USD</span></td>
    <td align="center" class="K">Contents</td>
    <td class="K"><input name="item" type="text" class="K" id="item" /></td>
  </tr>
  <tr>
    <td height="61" class="K">&nbsp;</td>
    <td>&nbsp; </td>
    <td align="center" class="K">Item #</td>
    <td class="K"><input name="contents" type="text" class="K" id="contents" value="* *" /></td>
  </tr>
</table>
<p>
  <input type="submit" value="Submit">
  <input type="reset" value="Reset">
</p>

PREVIEW.php

<style type="text/css">
<!--
.K {
 font-size: 14px;
 font-weight: normal;
 font-family: Tahoma, Geneva, sans-serif;
}
.bar {
 font:"Free 3 of 9 Extended";
 font-size:14px;
}
.K2 {
 font-size: 14px;
 font-family: tahoma, Geneva, sans-serif;
}
.ff {
 font-family: "Courier New", Courier, monospace;
}
-->
</style>
<table align="left">
  <tr>
    <td>
      <table width="97%" align="center" background="ss.jpg">
        <tr>
          <td>&nbsp;</td>
          <td class="ff">CONTENTS: <span class="K2"><?php echo " :" .$_POST["item"]. " "; ?></span></td>
        </tr>
      </table>
      <table>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
      <table width="800" align="center">
        <tr>
        <td class="K"><strong><U>SEND TO :</U></strong></td>
        <td class="K2">&nbsp;</td>
        <td class="K" align="right"><strong>FROM :</strong></td>
        <td class="K2">&nbsp;</td>
      </tr>
      <tr>
        <td width="12%" height="131" class="K">&nbsp;</td>
        <td align="justify" width="34%" class="K2"><table width="250">
            <tr>
              <td class="K2" style="text-transform:uppercase"><strong> <?php
 
echo nl2br(" " .$_POST["to"]. " ");
?></strong></td>
              </tr>
          </table>         </td>
        <td width="14%" class="K" align="center"><p>::</p>
          <p>::</p>
          <p>::</p>
          <p>::</p></td>
        <td align="justify" width="40%" class="K2"> My Address        </td>
      </tr>
      <tr>
        <td height="16" class="K">------------------</td>
        <td class="K2">--------------------------------------------------</td>
        <td class="K">---------------------</td>
        <td class="K">--------------------------------------------------------</td>
      </tr>
    </table>
      <table width="72%" align="center">
        <tr>
          <td align="center"><span style="font:Verdana, Geneva, sans-serif; font-size: 10px;"> :: Package Information :: </span></td>
        </tr>
      </table>
      <table  width="72%" align="center" >
        <tr align="left">
          <td width="11%" style="font:Verdana, Geneva, sans-serif; font-size: 10px;" height="20">*Content:</td>
          <td width="28%"  class="K2"><?php echo " " .$_POST["cat"]. " "; ?></td>
          <td width="8%" style="font:Verdana, Geneva, sans-serif; font-size: 10px;">*Weight:</td>
          <td width="31%" style="font:Verdana, Geneva, sans-serif; font-size: 10px;" class="K2"><?php echo " ".$_POST["wgt"]." "; ?> grams</td>
          <td width="9%" style="font:Verdana, Geneva, sans-serif; font-size: 10px;" class="K"><p>*Price:</td>
          <td width="13%" style="font:Verdana, Geneva, sans-serif; font-size: 10px;" class="K2"><?php echo " ".$_POST["usd"]." "; ?> USD</td>
        </tr>
      </table>
    <hr color="#CCCCCC" />
    <table width="100%">
      <tr>
        <td width="57%" height="67"><p>Item ID:</p>
          <font face="IDAutomationHC39M" color="#000000" size="+2"> <?php echo " " .$_POST["contents"]. " "; ?> </font> </td>
        <td width="43%"><p>Tracking Code:</p>
          <p>&nbsp;</p></td>
      </tr>
    </table>    <?php
echo "<input type='hidden' name='to' value='".$_POST["to"]."' />";
echo "<input type='hidden' name='from' value='".$_POST["from"]."' />";
echo "<input type='hidden' name='content' value='".$_POST["cat"]."' />";
echo "<input type='hidden' name='wgt' value='".$_POST["wgt"]."' />";
echo "<input type='hidden' name='usd' value='".$_POST["usd"]."' />";
echo "<input type='hidden' name='usd' value='".$_POST["contents"]."' />";
?></td>
  </tr>
</table>

its possible and very easy. but have you got the tables set up in your db if so just
this needs to be added to the preview page, with connection to ur db.

$to= $_POST["to"];
$from = $_POST["from"];
//etc
$result1=mysql_query("INSERT INTO tablename (tablerow1, tablerow2, tablerow3, ) VALUES ('$to', '$from', '$cat', '$wgt', '$usd', '$contents')");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.