Hi,
Am I trying to be too clever here?
I am trying to write a PHP page to enable me to enter values into a form
then write those values to a text file.
I want to use the form & table that displays these fileds and values in
different ways so am creating one page and parsing variables to it.
The problem appears to be in trying to write the values to a text file. The
page displays the field names correctly but when I submit the form and try
to write the values to a text file, separated by # what I get is
############## but no values !!!
Any help greatly appreciated .... Paul.
Config.php:
$filename = "./config.txt"
$fieldnames = array ("business_name ", "business_addre ss", "business_phone ");
// There are more but you get the idea
// Firstly if the file exists read the existing values and store them in an
array where $fieldname[$i] = $data[$i]
if(file_exists( $filename))
{
$fp = fopen($filename , "r");
$contents = fread($fp, filesize($filen ame));
$data = explode("#", $contents, 16);
for($i = 0; $i < 17; ++$i)
{
$fieldnames[$i] = $data[$i];
}
fclose($fp);
// Display the form in update mode with current values as defaults
$button = "update";
include("./config_table.ph p");
}
elseif($submit == "save" || $submit == "update")
{
// The form has been submitted so write the values to the text file
$fp = fopen($filename , "w+");
for($i = 0; $i < 17; ++$i)
{
fwrite($fp, $data[$i] . "#"); // uses the # symbol to separate data
items
}
fclose($fp);
print '<SPAN CLASS="message" >Your configuration values have been ' .
$submit . 'd successfully.</SPAN>';
}
else
{
// Display the form in install mode as this if the first time the file
has been run
$button = "save";
include("./config_table.ph p");
}
Config_table.ph p:
<FORM NAME="configura tion" METHOD="post" ACTION="config. php">
<TABLE>
<?php $f = 0; ?>
<TR><TD>Busines s Name</TD>
<TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo
$fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<?php ++$f; ?>
<TR><TD>Busines s Address</TD>
<TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo
$fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<?php ++$f; ?>
<TR><TD>Busines s Phone</TD>
<TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo
$fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<TR><TH COLSPAN="2"><IN PUT TYPE="submit" VALUE="<?php echo $button;
?>"> <INPU T TYPE="reset" VALUE="reset"></TH></TR></TABLE></FORM> 5 3796
Forgot to mention in the config_table.ph p page I am using the VALUE="<?php
echo $fieldnames[$f]; ?>" for testing only - saves me having to enter values
all the time ... would otherwise be $data array.
So in my text file I should expect to see
"business_name# business_addres s#business_phon e# etc ...
Paul.
"Paul C-T" <pa************ *****@hotmail.c om> wrote in message
news:40******** **************@ ptn-nntp-reader01.plus.n et... Hi,
Am I trying to be too clever here?
I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that displays these fileds and values in different ways so am creating one page and parsing variables to it. The problem appears to be in trying to write the values to a text file.
The page displays the field names correctly but when I submit the form and try to write the values to a text file, separated by # what I get is ############## but no values !!!
Any help greatly appreciated .... Paul.
Config.php:
$filename = "./config.txt" $fieldnames = array ("business_name ", "business_addre ss",
"business_phone "); // There are more but you get the idea
// Firstly if the file exists read the existing values and store them in
an array where $fieldname[$i] = $data[$i]
if(file_exists( $filename)) { $fp = fopen($filename , "r"); $contents = fread($fp, filesize($filen ame)); $data = explode("#", $contents, 16); for($i = 0; $i < 17; ++$i) { $fieldnames[$i] = $data[$i]; } fclose($fp);
// Display the form in update mode with current values as defaults
$button = "update"; include("./config_table.ph p"); }
elseif($submit == "save" || $submit == "update") {
// The form has been submitted so write the values to the text file
$fp = fopen($filename , "w+"); for($i = 0; $i < 17; ++$i) { fwrite($fp, $data[$i] . "#"); // uses the # symbol to separate data items } fclose($fp);
print '<SPAN CLASS="message" >Your configuration values have been ' . $submit . 'd successfully.</SPAN>'; }
else {
// Display the form in install mode as this if the first time the file has been run
$button = "save"; include("./config_table.ph p"); } Config_table.ph p:
<FORM NAME="configura tion" METHOD="post" ACTION="config. php">
<TABLE>
<?php $f = 0; ?>
<TR><TD>Busines s Name</TD> <TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo $fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<?php ++$f; ?>
<TR><TD>Busines s Address</TD> <TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo $fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<?php ++$f; ?>
<TR><TD>Busines s Phone</TD> <TD><INPUT TYPE="text" MAXLENGTH="255" SIZE="40" NAME="<?php echo $fieldnames[$f]; ?>" VALUE="<?php echo $fieldnames[$f]; ?>"></TD></TR>
<TR><TH COLSPAN="2"><IN PUT TYPE="submit" VALUE="<?php echo $button; ?>"> <INPU T TYPE="reset" VALUE="reset"></TH></TR></TABLE></FORM>
In article <40************ **********@ptn-nntp-reader01.plus.n et>, Paul C-T wrote: The problem appears to be in trying to write the values to a text file. The page displays the field names correctly but when I submit the form and try to write the values to a text file, separated by # what I get is ############## but no values !!!
What is the setting for register_global s?
If you do a little search on "missing values" in this newsgroup, you
won't believe how many times this question has been answered. Can't
believe ppl still bother to answer this question.
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Tim,
Not everyone is as unhelpful as you ... I tried searching through the 1500
messages but did not find the answer I needed ... hence the question.
;-)
Paul.
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2l******** ****@uni-berlin.de... In article <40************ **********@ptn-nntp-reader01.plus.n et>, Paul C-T
wrote: The problem appears to be in trying to write the values to a text file.
The page displays the field names correctly but when I submit the form and
try to write the values to a text file, separated by # what I get is ############## but no values !!!
What is the setting for register_global s?
If you do a little search on "missing values" in this newsgroup, you won't believe how many times this question has been answered. Can't believe ppl still bother to answer this question.
-- Tim Van Wassenhove <http://home.mysth.be/~timvw>
In article <40************ *********@ptn-nntp-reader03.plus.n et>, Paul C-T wrote: Tim,
Not everyone is as unhelpful as you ... I tried searching through the 1500 messages but did not find the answer I needed ... hence the question.
Well, i went to google, search the groups
comp.lang.php missing values. And the second hit already mentionned
register_global s... Guess i was lucky :d
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
"Paul C-T" <pa************ *****@hotmail.c om> wrote in message
news:40******** **************@ ptn-nntp-reader01.plus.n et... Forgot to mention in the config_table.ph p page I am using the VALUE="<?php echo $fieldnames[$f]; ?>" for testing only - saves me having to enter
values all the time ... would otherwise be $data array.
So in my text file I should expect to see "business_name# business_addres s#business_phon e# etc ...
As a piece of general advice, you'd be much better off using a XML file
format for this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: NotGiven |
last post by:
|
by: Yang Li Ke |
last post by:
Hi
I know that there is a meta tag function to get all meta tags from a url.
I am searching for a similar function that would get all values of a form.
something like :
<form>
<input type="text" name="name" size="10">
<input type="text" name="url" size="40">
</form>
|
by: Glyphman |
last post by:
I have a bunch of pages with long forms, with lots of input
types-text, radios, textareas, and the debugging process has become
overwhelming.
What I need to happen is to make sure that
1. Every field on the page is filled out-if not, a list of incorrect
fields is displayed, and any radio boxes that were checked still are
2. The fields are queried to a table in a database. (The table has the
same column names as the field names)
Here's...
|
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a table in MySQL with the path & filename to
the image.
I have successfully uploaded and performed an update query on the database,
but the problem I have is I cannot retain the primary key field in a
variable which is then used in a SQL update...
|
by: Randell D. |
last post by:
HELP!
I am determined to stick with this... I'm getting there... for those who
haven't read my earlier posts, I'm createing what should be a simple
function that I can call to check that required fields in a form have
values. I'm writing the values to the client using document.write only so
that I can confirm that the values are there to be played with - this is not
the final result so please (unless it's leading to the script failure)...
| |
by: hfk0 |
last post by:
Hi,
I'm new to ASP.net, SQL Server and visual studio.net, and I'm having
problem inserting and storing data from a web form to a SQL database.
I created a simple ASP.NET web form, a simple SQL database, a database
connection (using the SQlDataSource Web Control from the Toolbox), and
created the following stored procedure in Visual Studio.Net 2005:
|
by: Good Man |
last post by:
Hi
This is sort of a weird question, perhaps a bit off-topic...
I am on the 'edit' screen of a web form, and I have a bunch of variables
coming from a database that need to be placed into the form. In the
past, I have been using PHP to pre-populate each field, something like
<input type="text" id="firstName" value="<?= $first_name ?>" />
|
by: guitarromantic |
last post by:
Hey everyone,
I run a site with staff-submitted reviews, and most of them are written
by one author. However, we also do "multiple" reviews. Up until now I
just had a userid for a 'Multiple' account and submitted them under
that, but this makes it harder to print lists of all the reviews by one
person, so ideally I wanna make a multiple select form so we can just
select all the contributors and have the values saved in the database -
in...
|
by: Cerebral Believer |
last post by:
Hi I need help!
Forgive me I am a PHP newbie. I have a small script that enables me to send
a form from an HTML page. I want to use the HTML formatted form because the
design of my website is complex, and I don't want to have to mess around
with formatting a page using HTML within php. So basically the "action" of
the HTML page sends the form to "ProcReg.php". This is the code:
<?php
/* Script name: ProcReg.php
|
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,...
|
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...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |