Page 1 of 1
PDF Submit and $_POST
Posted: Tue Aug 07, 2007 3:49 pm
by littlemetz85
I've been working on this project for awhile now but still can't get it to work so I'm turning to all of you for some help. I have made a PDF application with a HTTP submit button at the bottom. This submits to a php script that I have on my server. What I want to do is to take the submitted data and save it as an XML file on my server. I have been using the $_POST method to get the data sent to the script but it puts it in an array. I can't figure out from here how to make it into an XML file. Any suggestions?
Thanks, Paul
Posted: Tue Aug 07, 2007 3:52 pm
by feyd
Posted: Tue Aug 07, 2007 4:39 pm
by littlemetz85
I tried that but it seems but $_POST seems to be putting all the text in a single part of the array so there is no way to separate it. Is there a different method that I should use instead of $_POST? Or a different way to format my PDF submit button?
Thanks, Paul
Posted: Tue Aug 07, 2007 4:41 pm
by feyd
It would probably help to show us what is being seen by PHP.
Posted: Tue Aug 07, 2007 4:48 pm
by littlemetz85
when I do a print_r($_POST) this is what shows:
PaulAddress=123 Fake LaneCity=MyCityCellPhoneNumber=1234567891Email=
MyMail@Gmail.com
I also get the same output using:
foreach ($data as $variable) {
echo "$variable";
}
It shows all my form data but is missing the name of the first text box.
Posted: Tue Aug 07, 2007 6:09 pm
by iknownothing
you can view individual POST elements like this:
Posted: Tue Aug 07, 2007 6:21 pm
by littlemetz85
so is there no generic way to save the whole file no matter what the fields are. So say we update the application to have different fields then we would have to go in and change the php script?
Posted: Tue Aug 07, 2007 6:30 pm
by iknownothing
I suppose you could save it as one string, and later on when you want to separate it, you could use explode or similar.
But if you add fields later on, it wont take long to amend the PHP file either.
Posted: Tue Aug 07, 2007 8:15 pm
by littlemetz85
That still didn't work for me. When I use:
print_r($_POST['name']);
If I use the first field on the form all that data from all the fields is printed and when I use the other fields non of the data is printed. I think the problem is that $_POST is creating an array with only one item and that one item is a string of the entire data output and is called by the first name on the form. Any ideas?
Posted: Tue Aug 07, 2007 8:24 pm
by iknownothing
littlemetz85 wrote:That still didn't work for me. When I use:
print_r($_POST['name']);
If I use the first field on the form all that data from all the fields is printed and when I use the other fields non of the data is printed. I think the problem is that $_POST is creating an array with only one item and that one item is a string of the entire data output and is called by the first name on the form. Any ideas?
do you actually have an elemnet in the form with the name "name". My example required you to put in your own variable.
Eg.
Code: Select all
<input type="text" name="first_name" />
<input type="text" name="last_name" />
would have the POST data as...
Code: Select all
$_POST['first_name'];
$_POST['last_name'];
Posted: Tue Aug 07, 2007 9:42 pm
by littlemetz85
yea i substituted "name" with my text box name and got those results
Posted: Tue Aug 07, 2007 9:52 pm
by iknownothing
can you post your code, including the form.
Posted: Tue Aug 07, 2007 10:16 pm
by littlemetz85
Sure,
The pdf is at
http://littlemetz85.110mb.com/Application.pdf
and the php script is at
http://littlemetz85.110mb.com/ApplicationSubmit.php
and the full file looks like:
Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<?php
echo "Name: ";
print_r ($_POST[txtName]);
echo "Address: ";
print_r ($_POST[txtAddress]);
echo "City: ";
print_r ($_POST[txtCity]);
echo "Thank You";
?>
</body>
</html>
I am using a free web server right now but it will be on a corporate server when it is done.