Jump to content

Recommended Posts

Hi, I've got a pdf catalog which posts an order to a php form.

 

The idea is that that the php page looks like an order form that the client can check before finally hitting 'submit' (i.e. along the lines of go to shopping cart).

I'd like the php page to be editable. Meaning clients can not only look at their echoed order, but change it before committing to it.

 

So the catalog order gets put into a php submit form with editable fields.

 

I've read that others have accomplished this with statements like:

 

 

value="<?php echo $clientName; ?>"

 

Which should fill the client name input box on the order form with the posted variable.

 

But it doesn't work properly for me, instead, the form field is filled with "<?xml version=" with the expected name on the line benath the input box and " /> on the line beneath that.

 

Placing the input box declaration entirely within php tags doesn't work either (exactly the same output).

 

<?php 
    echo ("Name: <input class=\"inputbox\" type=\"text\" name=\"clientName\"
maxlength=\"40\" value=\"$clientName\"><br>");
?>

 

Can anyone help?

Steve

 

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/
Share on other sites

Thanks for replying Pikachu2000.

 

The var is posted from a pdf and declared with:

$clientName = $_POST['clientName'];

As an earlier test I simply echoed all the posted variables & they were simply that--whatever was typed in the appropriate pdf entry field.

So if John Smith is the client's name then:

echo $clientName is John Smith

But value="<?php echo $clientName; ?>" is:

 

<?xml version=

John Smith

" />

where only the first line is in the input box.

Steve

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1269794
Share on other sites

That is echo on it's own. That's the odd part.

 

Post your entire code, it's obvious that SOMETHING is changing your variables. There's no way an echo in one place should be different than an echo in another place unless that variable was change.

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270088
Share on other sites

One idea: look at the source of the page when you echo the variable on its own. I'll bet the xml is there in the source, but not being rendered by the browser.

 

That shouldn't render considering the value is in the tag.

 

<?xml version= John Smith " /> Should not be displayed at all.

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270094
Share on other sites

Better to suggest something than stay silent :)

 

I think your best bet is to print_r( $_POST ); at the start of the script, then do it again right before you echo the values in the form.

 

To anyone reading - this is why developers avoid global variables, and prefer to do most of the dirty work in a local/function/class scope. It can become VERY hard to tell where these variables are changed if every included file/function/class is able to modify them.

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270096
Share on other sites

Thanks for trying to help me here. I'm beginning to suspect it's something to do with the fact the post come from a pdf, since no one's saying "You can't use value=\"$clientName\"

I'll try making a test submit html page and see if I can insert values that way (won't help with the problem though, the catalog is a pdf).

 

Here's the offending code:

I'll see if I can attach a pic of the output. (The clientName is 'too' sorry, was in a hurry & not thinking.)

 

 

 

<body>

<?php

    print_r( $_POST );

    $clientName= $_POST['clientName'];

 

 

echo $clientName;

 

    echo ("client Name: <input class=\"inputbox\" type=\"text\" name=\"clientName\"

maxlength=\"40\" value=\"$clientName\"><br>");

?>

    <form name="form1" method="post" action="">

    <input name="name" type="text" id="name" value="<?php echo $clientName; ?>">

    <form action="orderSent.php" method="post">

    <input type="submit" />

    </p>

    </form>

</body>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270099
Share on other sites

Sorry Pikachu2000, the 'too' is the name (!) i.e. not John but too. (I was in a hurry).

 

And that (above) is all the code in the current submit.php which receives the post--the actual source (of the post vars) is a pdf button (in a pdf catalog) set to 'submit a form to html' this sends the post to submit.php.

 

But I've just discovered the script above works fine by declaring:

$clientName = 'John';

i.e. hard code the var instead of getting it from $_POST.

 

So there're 'invisible' lines in the post received from the pdf, only revealed by a "value=" statement.

Any ideas how to strip them from the $_POST?

Steve

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270106
Share on other sites

I have no way of testing this, but in Acrobat, where you created the PDF form -

 

Highlight the submit button and click the XML Source tab. Below the tag, near the tag for the button, find and change format="formdata" to format="urlencoded"
Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270109
Share on other sites

Thanks PFMaBiSmAd,

 

Well, your suggestion sure lifted my mood for a while, and in fact it might lead to a workaround, but it didn't quite work.

 

I've been using acrobat to edit the pdf. It seems acrobat's HTML submit feature comes with weird formatting (as described above) and there's no way to remove it with acrobat (or Foxit). 

 

If anyone knows how i can remove this extra formatting with php after the POST then please let me know (all suggestions appreciated).

 

Acrobat won't let me change this formatting, however Adobe's life cycle designer does. Designer has format="urlencoded" as the default setting. The bummer is that designer won't pass my product code

 as quantity array. Rather it simply posts every field in the pdf (all mashed together, [prodCode_6747_] rather than prodCode[6747]). So at the moment it seems I can post values but lose the product array or visa versa (am still playing with this).

Once again If anyone knows how i can remove the extra formatting with php after the POST then please let me know (all suggestions appreciated).

Steve

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270148
Share on other sites

Hi, here's the whole submit page.

 

Currently all this page does is:

 

print_r($_Post)

echo a single posted var ($pharmName) (changed from clientName)

And try to fill two html fields (each time in a slightly different fashion) with the variable $pharmName.

 

If I can get the formatting issues to work I'll be adding your code (xyph ) from the earlier question you helped me with (i.e. where prodCode

 => qty was matched to product descriptions).

This current page is a test to see if I can fill an HTML form with all the values from a pdf catalog. There will (if this works) be several catalogs. Each will have the same address fields but different brands. 
Then will follow a list of ordered products and quantities.
The client will be able see their pdf order as a single web page before finally submitting it. As it's a form they'll also be able to make last minute changes.

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
    print_r( $_POST );
    $pharmName= $_POST['pharmName'];
    echo $pharmName;
   
    echo ("Pharmacy: <input class=\"inputbox\" type=\"text\" name=\"pharmName\"
maxlength=\"40\" value=\"$pharmName\"><br>");
?>
    <form name="form1" method="post" action="">
    <input name="name" type="text" id="name" value="<?php echo $pharmName; ?>">
    <form action="orderSent.php" method="post">
    <input type="submit" />
     </p>
    </form>
</body>
</html>

 

The attached pic shows the output when sent from an acrobat saved pdf. Only two products were ordered [6722] and [6724]. The problem is "<?xml version=" appears in the input box with the actual input below the box followed by these chars " />

 

Sending from a Adobe designer saved pdf correctly fills in the form (no extraneous chars) but the print_r($_Post) displays every field and button in the pdf and the products are in the form:

[prodCode_6723_] => 7 [prodCode_6730_] => [prodCode_6731_] =>

Meaning the products are not in an array and all products are present whether ordered or not. So I won't be able to loop through the prodCode array and display ordered products alongside their product descriptions. (Although possibly I could find a way to do this).

 

Steve

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270157
Share on other sites

Sorry, I don't get it. I did look at the source but it doesn't seem to have much info (all the php is server side). Here it is though. Is this what you're after? If not, please advise.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>



Array
(
)
<br /><br>	


</body>
</html>

 

The above is from the pdf with the prod array working but the bung value = fields (i.e. pdf saved with acrobat)

 

But view source is the same for bung product array with working value= fields (i.e. pdf saved with designer)

 

 

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270160
Share on other sites

Oops, I just looked with IE (was using firefox) seems there's a lot more on offer. Sorry,

Steve

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Array
(
    [Acc] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">1234</p></body>
    [contactName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">me</p></body>
    [pharmName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>
    [prodCode] => Array
        (
            [6722] => 2
            [6724] => 2
        )

    [suburbName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Somewhere</p></body>
    [wSalerName] => wholesaler
    [button6] => 
)
<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>Pharmacy: <input class="inputbox" type="text" name="pharmName"
maxlength="40" value="<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>"><br>    <form name="form1" method="post" action="">
    <input name="name" type="text" id="name" value="<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>">
    <form action="orderSent.php" method="post">
    <input type="submit" />
     </p>
    </form>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270161
Share on other sites

If anyone else ever experiences this particular horror, the answer is to uncheck rich text formatting on the posted pdf fields.

 

Thanks to everyone who helped me. I'm immensely grateful for your efforts.

 

I know how to make this work now--I can dump the address array--but I'd rather not. So I do have one last question.

Why isn't my

if ( $addrItem = 'pharmName' )

statement working? Somehow it appears to put the wrong value (the account number) into $pharmName when, of course, I'm tryying for the input pharmacy name.

 

Here's my page code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
echo 'This is post: <br>';
    print_r( $_POST );
echo '<br>';
echo '<br>';
echo '<br>';
$address = $_POST['addr'];
$orders = $_POST['prodCode'];
foreach( $address as $addrItem => $addrLine ) {

if ( $addrItem = 'pharmName' ) {
	echo 'fld name: '.$addrItem.' user typed: '.$addrLine;
    $pharmName = $addrLine;
	break;
}

echo '<br>';
}
echo '<br>';
   
    echo ("Pharmacy: <input class=\"inputbox\" type=\"text\" name=\"pharmName\"
maxlength=\"40\" value=\"$pharmName\"><br>");
?>
    <form name="form1" method="post" action="">
    <input name="name" type="text" id="name" value="<?php echo $pharmName; ?>">
    <form action="orderSent.php" method="post">
    <input type="submit" />
     </p>
    </form>
</body>
</html>

 

And here's the source (if that helps)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
This is post: <br>Array
(
    [addr] => Array
        (
            [Acc] => Acc num
            [contactName] => contact name
            [pharmName] => Pharm name
            [suburbName] => A suburb
            [wSalerName] => wsaler
        )

    [prodCode] => Array
        (
            [6722] => 2
            [6724] => 2
        )

    [button6] => 
)
<br><br><br>fld name: pharmName user typed: Acc num<br>Pharmacy: <input class="inputbox" type="text" name="pharmName"
maxlength="40" value="Acc num"><br>    <form name="form1" method="post" action="">
    <input name="name" type="text" id="name" value="Acc num">
    <form action="orderSent.php" method="post">
    <input type="submit" />
     </p>
    </form>
</body>
</html>

 

Steve

Link to comment
https://forums.phpfreaks.com/topic/247246-form-fill-problem/#findComment-1270179
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.