473,766 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving data from a form into a seperate .html file

I wrote this script here but I cannot get the script to save to the
correct month.html. Can someone tell me what is wrong with this code?

<html>
<head>
<title>Monthl y Bills</title>
</head>
<body>
<center><font size="4">Total Monthly Bills</font>
<form action="billcal culation.php" method="POST">
<br>
<select name="months">
<option value="January" name="month">Ja nuary</option>
<option value="February " name="month">Fe bruary</option>
<option value="March" name="month">Ma rch</option>
<option value="April" name="month">Ap ril</option>
<option value="May" name="month">Ma y</option>
<option value="June" name="month">Ju ne</option>
<option value="July" name="month">Ju ly</option>
<option value="August" name="month">Au gust</option>
<option value="Septembe r" name="month">Se ptember</option>
<option value="October" name="month">Oc tober</option>
<option value="November " name="month">No vember</option>
<option value="December " name="month">De cember</option>
</select><br><br>
<table border="0">
<td>Rent:</td><td><input type="text" name="apartment _rent"
size="5"></td><tr>
<td>Water & Sewage</td><td><input type="text" name="water_sew age"
size="5"></td><tr>
<td>Cell Phone:</td><td><input type="text" name="cell_phon e"
size="5"></td><tr>
<td>Cable & Internet:</td><td><input type="text" name="cable_int ernet"
size="5"></td><tr>
<td><center><in put type="submit" name="submit"
action="submit" ></center></td><td><input type="reset" name="reset"
action="reset"> </td></table>
</center></form>
<center><font size="4">Monthl y Bills for 2005-2006</font><br><br>

<?php

$fp = fopen("$_POST['month'] . ".html","a+ ");
$output = print "TEST";

$apartment_rent = $_POST['apartment_rent '];
$water_sewage = $_POST['water_sewage'];
$cell_phone = $_POST['cell_phone'];
$cable_internet = $_POST['cable_internet '];

$total_monthly_ bill = $apartment_rent + $water_sewage + $cell_phone +
$cable_internet ;

print "Bills for <b>{$_POST['months']}</b><br>";
print "Apartment rent: $apartment_rent <br>";
print "Water and sewage: $water_sewage <br>";
print "Verizon cell phone bill: $cell_phone <br>";
print "Time Warner cable bill: $cable_internet <br>";
print "Total monthly payment: $total_monthly_ bill <br>";
?>
</body>
</html>

Nov 30 '05 #1
7 2245
Brian said the following on 30/11/2005 20:01:
I wrote this script here but I cannot get the script to save to the
correct month.html. Can someone tell me what is wrong with this code?


<...SNIP CODE...>

Did you try turning error reporting on?

--
Oli
Nov 30 '05 #2
Brian said the following on 30/11/2005 20:01:
I wrote this script here but I cannot get the script to save to the
correct month.html. Can someone tell me what is wrong with this code?

<...SNIP CODE...>

Did you try turning error reporting on?

--
Oli
Nov 30 '05 #3
vdP
Brian wrote:
I wrote this script here but I cannot get the script to save to the
correct month.html. Can someone tell me what is wrong with this code?
<SNIP CODE> <?php

$fp = fopen("$_POST['month'] . ".html","a+ ");


There are five quotes(") here. I can hardly imagine that is right.

vdP
Nov 30 '05 #4

vdP wrote:
Brian wrote:
I wrote this script here but I cannot get the script to save to the
correct month.html. Can someone tell me what is wrong with this code?

<SNIP CODE>
<?php

$fp = fopen("$_POST['month'] . ".html","a+ ");


There are five quotes(") here. I can hardly imagine that is right.

vdP


Yep, make it:

$fp = fopen($_POST['month'] . ".html","a+ ");

iwp506

Nov 30 '05 #5
ok that worked i changed the code a little bit, now I'm getting an
error like this:
Fatal error: Function name must be a string in
/usr/local/www/billcalculation .php on line 36

$fp = fopen($_POST['month'] . ".html","a+ ");
$fwrite ($fp, $data);
fclose($fp);

$data = print "Apartment: $apartment_rent "; //want it to print that to
the new .html file.
thats what I have, why am I getting this error?

Dec 1 '05 #6
Fatal error: Function name must be a string in
/usr/local/www/billcalculation .php on line 36

$fp = fopen($_POST['month'] . ".html","a+ ");
$fwrite ($fp, $data);
fclose($fp); $data = print "Apartment: $apartment_rent "; //want it to print that to
the new .html file.


This is not a PHP problem.

---
Steve

Dec 1 '05 #7
vdP
Brian wrote:
ok that worked i changed the code a little bit, now I'm getting an
error like this:
Fatal error: Function name must be a string in
/usr/local/www/billcalculation .php on line 36

$fp = fopen($_POST['month'] . ".html","a+ ");
$fwrite ($fp, $data);
fclose($fp);

$data = print "Apartment: $apartment_rent "; //want it to print that to
the new .html file.
thats what I have, why am I getting this error?


A few things:
1. Read http://www.safalra.com/special/googlegroupsreply/ about how to
use Google groups.
2. I hope you defined $data before you try to write it to the new html-file.
3. (By far the most important point.) The print function outputs the
given string as normal html, i.e. you will see it in your browser if you
open billcalculation .php . The statement above assigns the result of the
print function (which is always the integer 1) to $data. Hence, the
number 1 should be written to the new html-file. Instead use
$data="Apartmen t: $apartment_rent ";
$fwrite ($fp, $data);
(And if you want to show it in billcalculation .php as well, throw in
print $data; )

Hope this helps.

vdP
Dec 1 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3293
by: Vijay | last post by:
I need to generate HTML files based on the some codes. One HTML file per code. I have the link (ex:http://123.234.345.456/WebPages/GetTestData.aspx?SomeCode=25), by passing the code as parameter I will get the page displayed. But I don't want to display it, instead save those files in one of the network directories that can be accessed by our third party vended web based application. How can I do this accessing and saving HTML files a...
2
3199
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
5
2727
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently considering: Page 1: Meeting Information input with link to a document upload page (this page...
8
4177
by: Yu SONG | last post by:
Hi all, What would be the most efficient way to save an array of floats to a file (in text format)? At the moment, my code looks like: /* * Saving an array of floats to a file
2
2226
by: jessDMiller | last post by:
I have no clue why the data from the form isn't saving into the database. What am I doing wrong? addAnnounce.php: <td align=top> <form action="index2.php" method="post">Heading:<br /><textarea name="heading" cols="50" rows="10"></textarea><br /><br />Announcement:<br /> <textarea name="announce" cols="50" rows="10"></textarea> <br /><br />Date:<br /><textarea name="date" cols="50" rows="10"></textarea><br /><br /><input...
13
1604
by: =?Utf-8?B?emlyb3M=?= | last post by:
We have a need, after a user fill out a form, to save that page (aspx) and to send it as attachment by email , and to save it to a database for later retrieval any ideas how to save the aspx with user data to file ? maybe image ? TIA
7
1961
by: Dave Kelly | last post by:
There has to be a name for what I want to do and I don't know what words to google for. I have a form here: http://www.texasflyfishers.org/firstpage.htm I want to submit it to the server and have it saved: 1. In a directory by the guides name which would be the variable 'describe11'. Create this directory if it does not already exist. 2. Create a special file name from the date and time submitted.
3
2469
by: pozze | last post by:
Hi, I've just made the change from ASP to .net. I have a file (code below) that saves a user submitted file to a MS SQL 2005 database. It collects the file name, file size, file type, and lastly the binary data for the file. I can sucessfully take the files out of the databse again and display them in a data grid. I would like to resize the submitted file to a fixed size (say 180 x 120) before I upload it to the database and do this without...
2
3380
by: RussCRM | last post by:
I want to use a command button, say "cmdDisplayImage" to display/ transfer a captured image from the ezVidCap1 control to an image or OLE box on the same form such as "PhotoPreview" (not sure which one is possible/best...perhaps someone can help me...I'm new at this.) I really don't want to "save" it first. Then, I want another command button such as "cmdSaveImage" to save the file to a folder (such as \\Server\Database\Images when...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10008
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9837
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.