Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Advise on Print then redirect

    At the bottom of the following script I have onClick=window.print()
    That work fine. What I need to happen is when the user clicks print, the form prints, then redirect the user to a that form again while retaining some but not all the information that was printed. How that make sense. Any thoughts?

    Thanks
    PHP Code:
    <?
    session_start
    ();
    include (
    "conn.php");
    $id $_POST['id'];
    ?>

    <html><body><form><center>
    <body background="white" text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A"></h3>
    </center>


    <?
    echo "<input type = 'hidden' name = 'id' value = '$id'>";

    if (
    $_POST['misc']!='N'$_POST['misc']=='Y';
    if (
    $_POST['year']!='N'$_POST['year']=='Y';
    if (
    $_POST['emergency']!='N'$_POST['emergency']=='Y';
    if (
    $_POST['stdservice']!='N'$_POST['stdservice']=='Y';
    if (
    $_POST['extra']!='N'$_POST['extra']=='Y';
    if (
    $_POST['contract']!='N'$_POST['contract']=='Y';
    if (isset(
    $_POST['$description']))


    $id=$_POST['id'];
    $recdate=$_POST['recdate'];
    $orderby=$_POST['orderby'];
    $issuedate=$_POST['issuedate'];
    $appoint=$_POST['appoint'];
    $atime=$_POST['atime'];
    $inspecteddate $_POST['inspecteddate'];
    $contractor=$_POST['contractor'];
    $workdoneby=$_POST['workdoneby'];
    $compdate=$_POST['compdate'];
    $ownersign=$_POST['ownersign'];
    $owndate=$_POST['owndate'];
    $contactdate $_POST['contactdate'];

    if (
    $id == 0)

    echo 
    "ERROR: Please Try Again";
    }
    else
    {

    $query "INSERT INTO csi (id,recdate, orderby,issuedate,appoint,atime, misc, year, emergency, stdservice, 

    contractor, description, workdoneby, compdate, ownersign,owndate, inspecteddate,extra, contract,contactdate) 

    values('$id','$recdate','$orderby','$issuedate', 

    '$appoint','$atime','$misc','$year','$emergency','$stdservice','$contractor','$description','$workdoneby','$c

    ompdate','$ownersign','$owndate','$inspecteddate','$extra','$contract','$contactdate')"
    ;
    $result mysql_query($query) or die("Could not insert");
    $woid mysql_insert_id();


    }


    ?>


    <?

    $query2 
    "SELECT DATE_FORMAT(date_add(cdate,interval 365 day),'%m-%d-%Y')  FROM customers where id = '$id'";
    $result2 mysql_query($query2);
    $row=mysql_fetch_row($result2);
    $cdate $row[0];
    echo 
    "<b>";
    echo 
    "Warranty Expires ";
    echo 
    $cdate;
    echo 
    "</b>";
    echo 
    "<br>";

    ?>
    <?


    $query 
    = ("SELECT * FROM communties where community ='$community'");
    $result mysql_query($query);
    $row=mysql_fetch_row($result); 


    ?>

    <html>

    <body background="white" text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A">
    <h1><p align=center>The Kirk Corporation</h1><center><h4>Service Order<br><? echo $row[1];?><br><? echo 

    $row[2];?><br>Phone <? echo $row[3];?><br>Fax <? echo $row[4];?></h4>
    <h3></h3></center>



    <?

    $query1 
    = ("SELECT * FROM customers where id = '$id' ");
    $result1 mysql_query($query1);
    $row=mysql_fetch_row($result1); 

    ?>

    <h4>
    Lot/Building <?echo $row['10']?><?echo $row['11']?><br><?echo $row[1]?></br>
    <?echo $row['2']?><br>
    <?echo $row['3']?>
    <?echo $row['4']?> 
    <?echo $row['5']?><br>
    <?echo $row['6']?>
    </h4> 


    <?


    $result 
    mysql_query ("select 

    woid,id,recdate,orderby,issuedate,appoint,atime,misc,year,emergency,stdservice,contractor,description,workdon

    eby,DATE_FORMAT(compdate,'%m/%d/%Y'),ownersign,owndate,extra,contract,closed,status,contactdate,inspecteddate

    ,DATE_FORMAT(closeddate,'%m/%d/%Y'),note,DATE_FORMAT(adjdate,'%m/%d/%Y') from csi where woid = '$woid'"
    ); 

    $rowmysql_fetch_row($result);

    echo 
    "Work Order # $woid";


    ?>



    <hr>
    <p align = center>Contractor <input type ="text" name ="contractor" value="<?echo $row[11]?>"> 
    Appointment Date <input type="text" name="appoint" size="8" value="<?echo date('m/d/Y'

    strtotime($row['5']))?>">Time <input type = "text" name = "atime" size = 6 value="<?echo 

    $row[6]?>"></center><p align=center>Adjusted Date <input type="text" name="adjdate" size="8" value= "<?echo 

    $row['25']?>">
    <p align = "center">Description</center><center><textarea name = \"description\" rows= 4 cols= 60><?echo 

    $row[12]?></textarea></center>

    <p align = center>Misc <input ="checkbox" name="misc" value="<?echo $row[7]?>"size = "1"> 1 Year <input 

    ="checkbox" name="year" value="<?echo $row[8]?>"size = "1">Emergency  <input ="checkbox" name="emergency" 

    value="<?echo $row[9]?>"size = "1">Standard Service Call  <input ="checkbox" name="stdservice" value="<?echo 

    $row[10]?>"size = "1"></center>


    <p align = center>Work done by <input type="text" name="workdoneby" size= "35" maxlength= 35 value ="<?echo 

    $row[13]?>"></center></p>
    <p align = center>Signature of Owner <input type = "text" name="ownersign" size= "30" maxlength=30 value 

    ="<?echo $row[15]?>">Date <input type ="text" name="closeddate" size="8" maxlength=8 value ="<?echo 

    $row[23]?>"></center>                  <p align=center>Above work satisfactorily completed</center> Extra 

    <input ="checkbox" name="extra"  value="<?echo $row[17]?>"size = "1"> Contract <input ="checkbox" 

    name="contract"  value="<?echo $row[18]?>"size = "1"> 
    <br>
    <hr>

    <p align = center>Construction Office</center>
    <p align = center>
    Received from Customer <input type="text" name="recdate" size="8" size="8" value="<?echo date('m/d/Y'

    strtotime($row['2']))?>">
    Customer Contacted <input type="text" name="contactdate" size="8"size="8" value="<?echo date('m/d/Y'

    strtotime($row['21']))?>"></center><p align =center> Ordered by <input type="text" name="orderby" size="20" 

    maxlength=20 value ="<?echo $row[3]?>">
    <body>Issued to Contractor <input type="text" name="issuedate" size="8" value="<?echo date('m/d/Y'

    strtotime($row['4']))?>"></a></center> 

    <br>
    <input type=Submit name=Submit style="font-size:15" value="Print" onclick="window.print();">
    <input type="button" value="Main" style="font-size:15" onClick="parent.location='managerstart.php'">

    </form>
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,539
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Using PHP to generate the form dynamically, then a separate
    print page using a Printer Friendly CSS style sheet. PHP script
    can return/or refresh the page with different information.

    Sort of more than you might need, but PHP would be the better way to go.

    Javascripting can be a problem for some users.

  • #3
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. Any idea where I might find some info on what you said?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •