473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Storing multiple-line variable in a php from form

6
Hi all,

I just have a quick question here:

I have this site:

http://irx.inf.elte.hu/~begoaai/pizzaboy/index2.html

It's sort of a pizza online order site, you can order pizza, you can specify how much do you want from the types, what size do you want, and wether if you want it to be delivered or not. That's nothing interesting, the javascript works, and it stores all this data to the textarea value on the right (If you klick on the button "Számolás". Now, I want that, if I click on the Button "Megrendelem!", it should store the textarea.value to a file named tarol.txt, with the sum of cost and the time of the order.

my php looks like this:

[PHP]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Köszönjük rendelését!</title>
</head>
<BODY background="ppbg2.jpg">
<H1><center><font color="white">PIZZA PETI-HEZ</font></H1></center>
<?php
$myFile = "tarol.txt";
$fh = fopen($myFile, 'a') or die("Nem tudom megnyitni a fájlt!");
$pmeret = $_POST['comments'];
$osszeg = $_POST['osszeg'];
$ido = date('Y-m-d, G:i');

fwrite($fh, $ido . ";" &pmeret ";" &osszeg ."\n");
fclose($fh);

?>
<br><center><H1><font color="white"><a class="uj" href="index2.html">Order another one!</a></font></H1></center>
</body>
</html>[/PHP]

I guess it's a standard file writing, but it doesn't actually print the pmeret textarea value to the file, instead, it prints something like:

2007-05-07, 22:53
0 2%0

So, That's my problem here.
May 7 '07 #1
8 2857
pbmods
5,821 Expert 4TB
[PHP]
fwrite($fh, $ido . ";" &pmeret ";" &osszeg ."\n");
[/PHP]
Try changing that to
[PHP]
fwrite($fh, $ido . ";" . $pmeret ";" . $osszeg ."\n");
[/PHP]

Incidentally, this would also work:

[PHP]
fwrite($fh, "$ido;$pmeret;$osszeg\n");
[/PHP]

http://www.php.net/manual/en/language.types.string.php
May 7 '07 #2
bendes
6
It doesn't work. Maybe the problem is that tha textarea value has multiple lines, that's what I'm thinking anyway...
May 8 '07 #3
devsusen
136 100+
Hi,

for debugging purpose try to print out the $post variable in ur php page and see if u r getting all the values correctly or not.

Instead of writing this way
[PHP]fwrite($fh, $ido . ";" &pmeret ";" &osszeg ."\n");[/PHP]
u can write like this
[PHP]
$val = $ido . ";" &pmeret ";" &osszeg ."\n";
if(fwrite($fh, $val) === FALSE)
echo "Error in file writing";
[/PHP]

there is no problem with getting values from a textarea and storing it in a file.

susen
May 8 '07 #4
Motoma
3,237 Expert 2GB
Try:
[PHP]
fwrite($fh, $ido . ";" . $pmeret . ";" . $osszeg . "\n");
[/PHP]

You see, the '&' character instructs PHP to perform a bitwise operation on the character string you are trying to built. Instead you need to utilize the concatenation operater '.' for this string operation to be successful.
May 9 '07 #5
pbmods
5,821 Expert 4TB
The only textarea on your page is named "tetel", and it's read-only.
May 9 '07 #6
bendes
6
Well, I did some modifications. First I thought it was the php that went wrong, so I did some experiments, and finally, after about 5 hours of cruel and madness search, I found out that it was not. In fact, the html was the problem, and the textarea had this line:

style="overflow:hidden;"

to hide the scrollbars, and when I removed that, it worked like a charm. However, it's still a mystery to me, how php can not get data from input text types, at least in my php. Anyway, I will replace the type of the 'sum of all costs' to textarea, and this should also work.

Now what you find at my previously mentioned website is the nearly finished version.

Thanks for all the help, I really appreciate it, You good people are members of a great community here! :)
May 9 '07 #7
pbmods
5,821 Expert 4TB
Verify that you're using the correct variable names. In your PHP, put this line somewhere:

[PHP]
print_r($_POST);
[/PHP]

And see what comes out. This is everything that your form sent to your script.
May 10 '07 #8
bendes
6
Thanks again, it helped, the sum's name I used was wrong in the php.
May 10 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
7
by: Benoit St-Jean | last post by:
I am looking at options/ways to store 12 million gif/jpg images in a database. Either we store a link to the file or we store the image itself in the database. Images will range from 4k to 35k in...
6
by: Kieran Benton | last post by:
Hi, I have quite a lot of metadata in a WinForms app that I'm currently storing within a hashtable, which is fine as long as I know the unique ID of the track (Im storing info on media files). Up...
5
by: | last post by:
I was wondering if there would be any significant performance increases by loading Xslt Files into the Application Variables if there were a single or maybe multiple XSLT file(s) that would be used...
2
by: Chris Murphy via DotNetMonster.com | last post by:
Hey all, just wondering if anyone can point me in the right direction. I'm developing a solution that allows a user to store multiple text-based content (like code snippets, notes, documents etc.)...
7
by: C G | last post by:
Dear All, What's the best way to store jpgs in postgresql to use in a web page? I tried to use large objects, but how would you extract them from a table to be viewed in a web-page without...
2
by: hendry.johan | last post by:
Hi, I'm currently developing an HR system which involves storing a lot of configurations per module, such as payroll module, absence/shift module, training module, etc. total: around 100...
22
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'...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
3
by: jeet232 | last post by:
I'm writing a search engine, i'll need to store giga bytes of data, and i'm dividing it in multiple machines and multiple structures; now, my question is that which is the best implementation for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.