html page

  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post January 27th, 2009, 6:32 pm

Need some help, trying creating an html page for and end user to type in the following info...
Address, name and zip code… after hitting submit it will populate to a word template (standard letter) with the fields address, name and zip code… it will place what they type in the html web page to the word doc… and open the word doc so they can print…
I am lost…

Any help will be much appreciated.
Thanks.
mase
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 27th, 2009, 6:32 pm

  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Joined: Jul 18, 2008
  • Posts: 239
  • Loc: Western Australia
  • Status: Offline

Post January 28th, 2009, 2:08 am

Well, you've come to the right place :)

Firstly, you need 2 files.

1: A html page (index.html, say), that the user writes the address and everything in. You'll need to create a form using input boxes (google "html form" for more information.

Code: [ Select ]
<form name="form1" method="post" action="post.php">
 Address: <input type="text" name="address" id="address">
</form>
  1. <form name="form1" method="post" action="post.php">
  2.  Address: <input type="text" name="address" id="address">
  3. </form>


See above under action it says "post.php"? That means that the html page will send the information in the form to the php page, for you to do things with.

2: That brings me to the second file, a php file. (I think php is the easiest way to do this, probably not the only solution.)

The php file needs to retrieve the information that's sent to it, and that's by using $_POST["address"]

You'll need to do something like this:

Code: [ Select ]
<?php
$address = $_POST["address"];
 
echo $address;
?>
  1. <?php
  2. $address = $_POST["address"];
  3.  
  4. echo $address;
  5. ?>


That'll display the address that the php file has been sent. When you've got the above two files working, try replaceing the 2nd file with the following code.
(This creates a word document called alex.doc, and should put the text "The address is $address" into it.)

Code: [ Select ]
<?php
$fp = fopen("alex.doc", 'w+');
$str = "<b>The address is ".%address.".</b>"
 
fwrite($fp, $str);
 
fclose($fp);
?>
  1. <?php
  2. $fp = fopen("alex.doc", 'w+');
  3. $str = "<b>The address is ".%address.".</b>"
  4.  
  5. fwrite($fp, $str);
  6.  
  7. fclose($fp);
  8. ?>


You'll need to upload these both to a server with php and all the usual things installed. Have a play around - see how you go.
  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post January 28th, 2009, 7:36 am

thanks alex89 i will take a stab at this... can I add fields to this?
  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Joined: Jul 18, 2008
  • Posts: 239
  • Loc: Western Australia
  • Status: Offline

Post January 28th, 2009, 7:41 am

Yeah, like this:

Code: [ Select ]
<form name="form1" method="post" action="post.php">
Address: <input type="text" name="address" id="address">
<input type="text" name="housenumber" id="housenumber">
<input type="text" name="state" id="state">
<input type="text" name="postcode" id="postcode">
</form>
  1. <form name="form1" method="post" action="post.php">
  2. Address: <input type="text" name="address" id="address">
  3. <input type="text" name="housenumber" id="housenumber">
  4. <input type="text" name="state" id="state">
  5. <input type="text" name="postcode" id="postcode">
  6. </form>


then in the php file:

Code: [ Select ]
<?php
$address = $_POST["address"];
$number= $_POST["housenumber"];
$state = $_POST["state"];
$postcode = $_POST["postcode"];
 
echo $address;
echo "<br />";
echo $number;
echo "<br />";
echo $state;
echo "<br />";
echo $postcode;
 
?>
 
  1. <?php
  2. $address = $_POST["address"];
  3. $number= $_POST["housenumber"];
  4. $state = $_POST["state"];
  5. $postcode = $_POST["postcode"];
  6.  
  7. echo $address;
  8. echo "<br />";
  9. echo $number;
  10. echo "<br />";
  11. echo $state;
  12. echo "<br />";
  13. echo $postcode;
  14.  
  15. ?>
  16.  


Or however you want. If you give me a rough format for your letter I'll help out with the template :)
  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post February 4th, 2009, 12:30 pm

thanks alax89 sorry i did not reply

i am going to try this today and let you know


But thank you for your help,,,
  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post February 5th, 2009, 3:19 pm

Hi alax89 need some help.
i get a blank web page.
and word don't open up... i up load the file a server that uses php.
file one mailmerge.html,post.php and hwpt2.doc.
in the word tmeplaet the area to fill look like this, i use mail merge wizard to do this. this is a pre-type letter.
«Date»
To: «Company_Name»
«Address»
«City», «State» «ZIP_Code»


please take a look at my code and see whare i went wrong.

post.php (codes)

Code: [ Select ]
<?php

$Date =$_POST ["Date"];
$Amount = $_POST ["Amount"];
$Company_Name = $_POST ["Company_Name"];
$Address = $_POST["Address"];
$City= $_POST["City"];
$State = $_POST["State"];
$ZIP_Code = $_POST["ZIP_Code"];
$Specialists_Name = $_POST ["Specialists_Name"];
$Ext = $_POST ["Ext"];
$Cell = $_POST ["Cell"];
$Agent = $_POST ["Agent"];
$No_1 = $_POST ["No_1"];
$No_2 = $_POST ["No_2"];
$No_3 = $_POST ["No_3"];
$Total_Payments = $_POST ["Total_Payments"];

echo $Date;
echo "<br />";
echo $Amount;
echo "<br />";
echo $Company_Name;
echo "<br />";
echo $Address;
echo "<br />";
echo $City;
echo "<br />"
echo $State;
echo "<br />";
echo $ZIP_Code;
echo "<br />";
echo $Specialists_Name;
echo "<br />";
echo $Ext;
echo "<br />"
echo $Cell;
echo "<br />";
echo $Agent;
echo "<br />";
echo $No_1;
echo "<br />";
echo $No_2;
echo "<br />";
echo $No_3;
echo $Total_Payments



$fp = fopen("HWPT2.doc", 'w+');
fwrite($fp, $str);
fclose($fp);


?>



mailmerge.html (code)
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="generator" content="Web Page Maker">

</HEAD>
<BODY bgColor="#808080">
<form name="form1" method="post" action="post.php">
<div style="position:absolute; overflow:hidden; left:219px; top:243px; width:45px; height:22px; z-index:15">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Date:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:368px; top:243px; width:54px; height:22px; z-index:16">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Amount:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:217px; top:188px; width:461px; height:494px; z-index:0; background-color:#C0C0C0">
</DIV>
<div style="position:absolute; overflow:hidden; left:219px; top:291px; width:100px; height:22px; z-index:18">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Company Name:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:261px; top:325px; width:55px; height:22px; z-index:19">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Address:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:287px; top:355px; width:30px; height:22px; z-index:20">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>City:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:426px; top:355px; width:45px; height:22px; z-index:21">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>State:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:515px; top:356px; width:64px; height:22px; z-index:22">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Zip Code:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:218px; top:415px; width:104px; height:22px; z-index:23">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Specialists Name:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:223px; top:450px; width:103px; height:22px; z-index:24">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Phone Extension:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:446px; top:450px; width:33px; height:22px; z-index:25">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Cell:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:321px; top:487px; width:93px; height:22px; z-index:26">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Agent Number:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:239px; top:576px; width:45px; height:22px; z-index:27">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>NO. 1:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:383px; top:541px; width:122px; height:22px; z-index:28">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV><FONT style="font-size:12pt"><B>Payment Info</B></FONT></DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:379px; top:576px; width:45px; height:22px; z-index:29">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>NO. 2:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:539px; top:575px; width:45px; height:22px; z-index:30">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>NO. 3:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:323px; top:627px; width:94px; height:22px; z-index:31">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV>Total Payment:</DIV>
<DIV>&nbsp;</DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:327px; top:163px; width:253px; height:23px; z-index:32">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV><FONT style="font-size:11pt"><B>WELCOM PACKAGE MAIL MERGE</B></FONT></DIV>
</FONT>
</DIV>
<div style="position:absolute; overflow:hidden; left:230px; top:27px; width:306px; height:105px; z-index:33"><img width=306 height=105 border=0 src="images/homesavers1.bmp"></DIV>
<div style="position:absolute; overflow:hidden; left:536px; top:81px; width:131px; height:52px; z-index:34"><img width=131 height=52 border=0 src="images/permid.bmp"></DIV>
<div style="position:absolute; overflow:hidden; left:521px; top:132px; width:150px; height:30px; z-index:35">
<FONT style="font-size:10pt" color=#000000 face="Tahoma">
<DIV><FONT style="font-size:16pt"><B>Rescue Group</B></FONT></DIV>
</FONT>
</DIV>
<input name="$Date" type="text" style="position:absolute;width:110px;left:253px;top:240px;z-index:1">
<input name="$Amount" value="$" type="text" style="position:absolute;width:149px;left:418px;top:239px;z-index:2">
<input name="$City" type="text" style="position:absolute;width:110px;left:313px;top:351px;z-index:3">
<input name="$Address" type="text" style="position:absolute;width:200px;left:314px;top:322px;z-index:4">
<input name="$State" type="text" style="position:absolute;width:52px;left:461px;top:352px;z-index:5">
<input name="$ZIP_Code" type="text" style="position:absolute;width:78px;left:570px;top:353px;z-index:6">
<input name="$Specialists_Name" type="text" style="position:absolute;width:213px;left:321px;top:412px;z-index:7">
<input name="$Ext" type="text" style="position:absolute;width:104px;left:321px;top:447px;z-index:8">
<input name="$Cell" type="text" style="position:absolute;width:153px;left:474px;top:447px;z-index:9">
<input name="$Agent" type="text" style="position:absolute;width:65px;left:413px;top:483px;z-index:10">
<input name="$No_1" value="$" type="text" style="position:absolute;width:88px;left:283px;top:572px;z-index:11">
<input name="$No_2" value="$" type="text" style="position:absolute;width:107px;left:424px;top:572px;z-index:12">
<input name="$No_3" value="$" type="text" style="position:absolute;width:90px;left:581px;top:570px;z-index:13">
<input name="$Total_Payments" type="text" style="position:absolute;width:99px;left:417px;top:623px;z-index:14">
<input name="$Company_Name" type="text" style="position:absolute;width:252px;left:315px;top:288px;z-index:17">
<input type="submit" value="Submit Query" style="position:absolute;left:558px;top:656px;z-index:36">
</form>
</BODY>
</HTML>
  1. <?php
  2. $Date =$_POST ["Date"];
  3. $Amount = $_POST ["Amount"];
  4. $Company_Name = $_POST ["Company_Name"];
  5. $Address = $_POST["Address"];
  6. $City= $_POST["City"];
  7. $State = $_POST["State"];
  8. $ZIP_Code = $_POST["ZIP_Code"];
  9. $Specialists_Name = $_POST ["Specialists_Name"];
  10. $Ext = $_POST ["Ext"];
  11. $Cell = $_POST ["Cell"];
  12. $Agent = $_POST ["Agent"];
  13. $No_1 = $_POST ["No_1"];
  14. $No_2 = $_POST ["No_2"];
  15. $No_3 = $_POST ["No_3"];
  16. $Total_Payments = $_POST ["Total_Payments"];
  17. echo $Date;
  18. echo "<br />";
  19. echo $Amount;
  20. echo "<br />";
  21. echo $Company_Name;
  22. echo "<br />";
  23. echo $Address;
  24. echo "<br />";
  25. echo $City;
  26. echo "<br />"
  27. echo $State;
  28. echo "<br />";
  29. echo $ZIP_Code;
  30. echo "<br />";
  31. echo $Specialists_Name;
  32. echo "<br />";
  33. echo $Ext;
  34. echo "<br />"
  35. echo $Cell;
  36. echo "<br />";
  37. echo $Agent;
  38. echo "<br />";
  39. echo $No_1;
  40. echo "<br />";
  41. echo $No_2;
  42. echo "<br />";
  43. echo $No_3;
  44. echo $Total_Payments
  45. $fp = fopen("HWPT2.doc", 'w+');
  46. fwrite($fp, $str);
  47. fclose($fp);
  48. ?>
  49. mailmerge.html (code)
  50. <HTML>
  51. <HEAD>
  52. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  53. <meta name="generator" content="Web Page Maker">
  54. </HEAD>
  55. <BODY bgColor="#808080">
  56. <form name="form1" method="post" action="post.php">
  57. <div style="position:absolute; overflow:hidden; left:219px; top:243px; width:45px; height:22px; z-index:15">
  58. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  59. <DIV>Date:</DIV>
  60. <DIV>&nbsp;</DIV>
  61. </FONT>
  62. </DIV>
  63. <div style="position:absolute; overflow:hidden; left:368px; top:243px; width:54px; height:22px; z-index:16">
  64. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  65. <DIV>Amount:</DIV>
  66. <DIV>&nbsp;</DIV>
  67. </FONT>
  68. </DIV>
  69. <div style="position:absolute; overflow:hidden; left:217px; top:188px; width:461px; height:494px; z-index:0; background-color:#C0C0C0">
  70. </DIV>
  71. <div style="position:absolute; overflow:hidden; left:219px; top:291px; width:100px; height:22px; z-index:18">
  72. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  73. <DIV>Company Name:</DIV>
  74. <DIV>&nbsp;</DIV>
  75. </FONT>
  76. </DIV>
  77. <div style="position:absolute; overflow:hidden; left:261px; top:325px; width:55px; height:22px; z-index:19">
  78. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  79. <DIV>Address:</DIV>
  80. <DIV>&nbsp;</DIV>
  81. </FONT>
  82. </DIV>
  83. <div style="position:absolute; overflow:hidden; left:287px; top:355px; width:30px; height:22px; z-index:20">
  84. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  85. <DIV>City:</DIV>
  86. <DIV>&nbsp;</DIV>
  87. </FONT>
  88. </DIV>
  89. <div style="position:absolute; overflow:hidden; left:426px; top:355px; width:45px; height:22px; z-index:21">
  90. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  91. <DIV>State:</DIV>
  92. <DIV>&nbsp;</DIV>
  93. </FONT>
  94. </DIV>
  95. <div style="position:absolute; overflow:hidden; left:515px; top:356px; width:64px; height:22px; z-index:22">
  96. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  97. <DIV>Zip Code:</DIV>
  98. <DIV>&nbsp;</DIV>
  99. </FONT>
  100. </DIV>
  101. <div style="position:absolute; overflow:hidden; left:218px; top:415px; width:104px; height:22px; z-index:23">
  102. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  103. <DIV>Specialists Name:</DIV>
  104. <DIV>&nbsp;</DIV>
  105. </FONT>
  106. </DIV>
  107. <div style="position:absolute; overflow:hidden; left:223px; top:450px; width:103px; height:22px; z-index:24">
  108. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  109. <DIV>Phone Extension:</DIV>
  110. <DIV>&nbsp;</DIV>
  111. </FONT>
  112. </DIV>
  113. <div style="position:absolute; overflow:hidden; left:446px; top:450px; width:33px; height:22px; z-index:25">
  114. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  115. <DIV>Cell:</DIV>
  116. <DIV>&nbsp;</DIV>
  117. </FONT>
  118. </DIV>
  119. <div style="position:absolute; overflow:hidden; left:321px; top:487px; width:93px; height:22px; z-index:26">
  120. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  121. <DIV>Agent Number:</DIV>
  122. <DIV>&nbsp;</DIV>
  123. </FONT>
  124. </DIV>
  125. <div style="position:absolute; overflow:hidden; left:239px; top:576px; width:45px; height:22px; z-index:27">
  126. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  127. <DIV>NO. 1:</DIV>
  128. <DIV>&nbsp;</DIV>
  129. </FONT>
  130. </DIV>
  131. <div style="position:absolute; overflow:hidden; left:383px; top:541px; width:122px; height:22px; z-index:28">
  132. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  133. <DIV><FONT style="font-size:12pt"><B>Payment Info</B></FONT></DIV>
  134. <DIV>&nbsp;</DIV>
  135. </FONT>
  136. </DIV>
  137. <div style="position:absolute; overflow:hidden; left:379px; top:576px; width:45px; height:22px; z-index:29">
  138. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  139. <DIV>NO. 2:</DIV>
  140. <DIV>&nbsp;</DIV>
  141. </FONT>
  142. </DIV>
  143. <div style="position:absolute; overflow:hidden; left:539px; top:575px; width:45px; height:22px; z-index:30">
  144. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  145. <DIV>NO. 3:</DIV>
  146. <DIV>&nbsp;</DIV>
  147. </FONT>
  148. </DIV>
  149. <div style="position:absolute; overflow:hidden; left:323px; top:627px; width:94px; height:22px; z-index:31">
  150. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  151. <DIV>Total Payment:</DIV>
  152. <DIV>&nbsp;</DIV>
  153. </FONT>
  154. </DIV>
  155. <div style="position:absolute; overflow:hidden; left:327px; top:163px; width:253px; height:23px; z-index:32">
  156. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  157. <DIV><FONT style="font-size:11pt"><B>WELCOM PACKAGE MAIL MERGE</B></FONT></DIV>
  158. </FONT>
  159. </DIV>
  160. <div style="position:absolute; overflow:hidden; left:230px; top:27px; width:306px; height:105px; z-index:33"><img width=306 height=105 border=0 src="images/homesavers1.bmp"></DIV>
  161. <div style="position:absolute; overflow:hidden; left:536px; top:81px; width:131px; height:52px; z-index:34"><img width=131 height=52 border=0 src="images/permid.bmp"></DIV>
  162. <div style="position:absolute; overflow:hidden; left:521px; top:132px; width:150px; height:30px; z-index:35">
  163. <FONT style="font-size:10pt" color=#000000 face="Tahoma">
  164. <DIV><FONT style="font-size:16pt"><B>Rescue Group</B></FONT></DIV>
  165. </FONT>
  166. </DIV>
  167. <input name="$Date" type="text" style="position:absolute;width:110px;left:253px;top:240px;z-index:1">
  168. <input name="$Amount" value="$" type="text" style="position:absolute;width:149px;left:418px;top:239px;z-index:2">
  169. <input name="$City" type="text" style="position:absolute;width:110px;left:313px;top:351px;z-index:3">
  170. <input name="$Address" type="text" style="position:absolute;width:200px;left:314px;top:322px;z-index:4">
  171. <input name="$State" type="text" style="position:absolute;width:52px;left:461px;top:352px;z-index:5">
  172. <input name="$ZIP_Code" type="text" style="position:absolute;width:78px;left:570px;top:353px;z-index:6">
  173. <input name="$Specialists_Name" type="text" style="position:absolute;width:213px;left:321px;top:412px;z-index:7">
  174. <input name="$Ext" type="text" style="position:absolute;width:104px;left:321px;top:447px;z-index:8">
  175. <input name="$Cell" type="text" style="position:absolute;width:153px;left:474px;top:447px;z-index:9">
  176. <input name="$Agent" type="text" style="position:absolute;width:65px;left:413px;top:483px;z-index:10">
  177. <input name="$No_1" value="$" type="text" style="position:absolute;width:88px;left:283px;top:572px;z-index:11">
  178. <input name="$No_2" value="$" type="text" style="position:absolute;width:107px;left:424px;top:572px;z-index:12">
  179. <input name="$No_3" value="$" type="text" style="position:absolute;width:90px;left:581px;top:570px;z-index:13">
  180. <input name="$Total_Payments" type="text" style="position:absolute;width:99px;left:417px;top:623px;z-index:14">
  181. <input name="$Company_Name" type="text" style="position:absolute;width:252px;left:315px;top:288px;z-index:17">
  182. <input type="submit" value="Submit Query" style="position:absolute;left:558px;top:656px;z-index:36">
  183. </form>
  184. </BODY>
  185. </HTML>
Moderator Remark: Code tags added
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post February 5th, 2009, 6:16 pm

Your doing it wrong... Alex didn't tell you the bigger part of it... he just told you the very basics and assumed you knew how to fill in the blanks.

Here is what I did that should work. I haven't tested it since I don't have Microsoft Word so I can't test it, but here is the untested function. I don't know if it'll work because of the headers... I could take more time and create a full functional function to do what you want which would force you to download the document with the headers in place, but I don't have any desire to.

PHP Code: [ Select ]
<?php
$Date = $_POST ["Date"];
$Amount = $_POST ["Amount"];
$Company_Name = $_POST ["Company_Name"];
$Address = $_POST["Address"];
$City= $_POST["City"];
$State = $_POST["State"];
$ZIP_Code = $_POST["ZIP_Code"];
$Specialists_Name = $_POST ["Specialists_Name"];
$Ext = $_POST ["Ext"];
$Cell = $_POST ["Cell"];
$Agent = $_POST ["Agent"];
$No_1 = $_POST ["No_1"];
$No_2 = $_POST ["No_2"];
$No_3 = $_POST ["No_3"];
$Total_Payments = $_POST ["Total_Payments"];
 
if(fopen("HWPT2.doc", 'r+'))
{
   $filesize = filesize('HWPT2.doc');
   $str = fread('HWPT2.doc', $filesize);
   
   $str = str_replace("«Date»",$Date,$str);
   $str = str_replace("«Company_Name»",$Company_Name,$str);
   $str = str_replace("«Address» ",$Address,$str);
   $str = str_replace("«City»", $City,$str);
   $str = str_replace("«State»", $State,$str);
   $str = str_replace("«ZIP_Code»",$ZIP_Code,$str);
 
   if(fwrite($fp, $str))
   {
      echo 'File created successfully';
   }
   fclose($fp);
}
else
{
   echo 'Failed to retrieve the page';
}
?>
  1. <?php
  2. $Date = $_POST ["Date"];
  3. $Amount = $_POST ["Amount"];
  4. $Company_Name = $_POST ["Company_Name"];
  5. $Address = $_POST["Address"];
  6. $City= $_POST["City"];
  7. $State = $_POST["State"];
  8. $ZIP_Code = $_POST["ZIP_Code"];
  9. $Specialists_Name = $_POST ["Specialists_Name"];
  10. $Ext = $_POST ["Ext"];
  11. $Cell = $_POST ["Cell"];
  12. $Agent = $_POST ["Agent"];
  13. $No_1 = $_POST ["No_1"];
  14. $No_2 = $_POST ["No_2"];
  15. $No_3 = $_POST ["No_3"];
  16. $Total_Payments = $_POST ["Total_Payments"];
  17.  
  18. if(fopen("HWPT2.doc", 'r+'))
  19. {
  20.    $filesize = filesize('HWPT2.doc');
  21.    $str = fread('HWPT2.doc', $filesize);
  22.    
  23.    $str = str_replace("«Date»",$Date,$str);
  24.    $str = str_replace("«Company_Name»",$Company_Name,$str);
  25.    $str = str_replace("«Address» ",$Address,$str);
  26.    $str = str_replace("«City»", $City,$str);
  27.    $str = str_replace("«State»", $State,$str);
  28.    $str = str_replace("«ZIP_Code»",$ZIP_Code,$str);
  29.  
  30.    if(fwrite($fp, $str))
  31.    {
  32.       echo 'File created successfully';
  33.    }
  34.    fclose($fp);
  35. }
  36. else
  37. {
  38.    echo 'Failed to retrieve the page';
  39. }
  40. ?>

Try that and tell me what you get.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post February 5th, 2009, 7:43 pm

thanks Bogey

i will try and woke on this. complet it myself

thank you very much.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post February 5th, 2009, 7:51 pm

Alright :) Hope you get it working.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Joined: Jul 18, 2008
  • Posts: 239
  • Loc: Western Australia
  • Status: Offline

Post February 5th, 2009, 8:38 pm

Thanks Bogey, I go away for 2 days and you steal my thunder. :P
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post February 5th, 2009, 8:59 pm

alex89 wrote:
Thanks Bogey, I go away for 2 days and you steal my thunder. :P

That's because lightning comes before thunder :)
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • mase
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jan 27, 2009
  • Posts: 6
  • Status: Offline

Post February 10th, 2009, 6:09 pm

Thanks Bogey and Alex89 for all your help but i can't get this thing to work, i get a blank back. on the bottom is say done... will not open up the doc. file nor change it... code are

post.php
Code: [ Select ]
<?php

$Date =$_POST ["Date"];
$Amount = $_POST ["Amount"];
$Company_Name = $_POST ["Company_Name"];
$Address = $_POST["Address"];
$City= $_POST["City"];
$State = $_POST["State"];
$ZIP_Code = $_POST["ZIP_Code"];
$Specialists_Name = $_POST ["Specialists_Name"];
$Ext = $_POST ["Ext"];
$Cell = $_POST ["Cell"];
$Agent = $_POST ["Agent"];
$No_1 = $_POST ["No_1"];
$No_2 = $_POST ["No_2"];
$No_3 = $_POST ["No_3"];
$Total_Payments = $_POST ["Total_Payments"];

if(fopen("HWPT2.doc", 'r+'))
{
    $filesize = filesize('HWPT2.doc');
    $str = fread('HWPT2.doc', $filesize);
    
    $str = str_replace("«Date»",$Date,$str);
    $str = str_replace("«Amount»",$Amount,$str);
    $str = str_replace("«Company_Name»",$Company_Name,$str);
    $str = str_replace("«Address» ",$Address,$str);
    $str = str_replace("«City»", $City,$str);
    $str = str_replace("«State»", $State,$str);
    $str = str_replace("«ZIP_Code»",$ZIP_Code,$str);
    $str = str_replace("«Specialists_Name»",$Specialists_Name,$str);
    $str = str_replace("«Ext»",$Ext,$str);
    $str = str_replace("«Cell»",$Cell,$str);
    $str = str_replace("«Agent»",$Agent,$str);
    $str = str_replace("«No_1»",$No_1,$str);
    $str = str_replace("«No_2»",$No_2,$str);
    $str = str_replace("«No_3»",$No_3,$str);
    $str = str_replace("«Total_Payments»",$Total_Payments,$str);


    if(fwrite($fp, $str))
    {
        echo 'File created successfully';
    }
    fclose($fp);
}
else
{
echo 'Failed to retrieve the page';

}

?>
  1. <?php
  2. $Date =$_POST ["Date"];
  3. $Amount = $_POST ["Amount"];
  4. $Company_Name = $_POST ["Company_Name"];
  5. $Address = $_POST["Address"];
  6. $City= $_POST["City"];
  7. $State = $_POST["State"];
  8. $ZIP_Code = $_POST["ZIP_Code"];
  9. $Specialists_Name = $_POST ["Specialists_Name"];
  10. $Ext = $_POST ["Ext"];
  11. $Cell = $_POST ["Cell"];
  12. $Agent = $_POST ["Agent"];
  13. $No_1 = $_POST ["No_1"];
  14. $No_2 = $_POST ["No_2"];
  15. $No_3 = $_POST ["No_3"];
  16. $Total_Payments = $_POST ["Total_Payments"];
  17. if(fopen("HWPT2.doc", 'r+'))
  18. {
  19.     $filesize = filesize('HWPT2.doc');
  20.     $str = fread('HWPT2.doc', $filesize);
  21.     
  22.     $str = str_replace("«Date»",$Date,$str);
  23.     $str = str_replace("«Amount»",$Amount,$str);
  24.     $str = str_replace("«Company_Name»",$Company_Name,$str);
  25.     $str = str_replace("«Address» ",$Address,$str);
  26.     $str = str_replace("«City»", $City,$str);
  27.     $str = str_replace("«State»", $State,$str);
  28.     $str = str_replace("«ZIP_Code»",$ZIP_Code,$str);
  29.     $str = str_replace("«Specialists_Name»",$Specialists_Name,$str);
  30.     $str = str_replace("«Ext»",$Ext,$str);
  31.     $str = str_replace("«Cell»",$Cell,$str);
  32.     $str = str_replace("«Agent»",$Agent,$str);
  33.     $str = str_replace("«No_1»",$No_1,$str);
  34.     $str = str_replace("«No_2»",$No_2,$str);
  35.     $str = str_replace("«No_3»",$No_3,$str);
  36.     $str = str_replace("«Total_Payments»",$Total_Payments,$str);
  37.     if(fwrite($fp, $str))
  38.     {
  39.         echo 'File created successfully';
  40.     }
  41.     fclose($fp);
  42. }
  43. else
  44. {
  45. echo 'Failed to retrieve the page';
  46. }
  47. ?>




mail.html

Code: [ Select ]
<form name="form1" method="post" action="post.php">
Address: <input type="text" name="Aaddress" id="Address">
Company Name: <input type="text" name="Company_Name" id="Company_Name">
State: <input type="text" name="State" id="State">
Zip Code: <input type="text" name="ZIP_Code" id="ZIP_Code">
<INPUT TYPE=SUBMIT>
</form>
  1. <form name="form1" method="post" action="post.php">
  2. Address: <input type="text" name="Aaddress" id="Address">
  3. Company Name: <input type="text" name="Company_Name" id="Company_Name">
  4. State: <input type="text" name="State" id="State">
  5. Zip Code: <input type="text" name="ZIP_Code" id="ZIP_Code">
  6. <INPUT TYPE=SUBMIT>
  7. </form>



i am trying to edit jest those area for now... to see how it works.
Moderator Remark: Code tags added
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post February 10th, 2009, 8:48 pm

your $fp is not defined...

Code: [ Select ]
$fp = fopen("HWPT2.doc", 'r+');
if($fp)
{
$filesize = filesize('HWPT2.doc');
$str = fread('HWPT2.doc', $filesize);
 
// and so on...
 
  1. $fp = fopen("HWPT2.doc", 'r+');
  2. if($fp)
  3. {
  4. $filesize = filesize('HWPT2.doc');
  5. $str = fread('HWPT2.doc', $filesize);
  6.  
  7. // and so on...
  8.  

By the way, add the [code]...[ /code] blocks to your codes before a moderator notices it :lol:

(Looking back, I forgot to define that variable in my example above... sorry about that)
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 297 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.