Jump to content

[SOLVED] proper quoting to pass variable inside echo statement


aolong

Recommended Posts

When I use the following code, I'm getting two sets of $results echoed. If I remove the second hidden input, everything is fine. I can't seem to see my error and hope a fresh set of eyes and someone with more experience may shed some light on this. Pretty sure it's my quoting inside the second hidden input since $result is about 200 characters long and includes spaces and html code.

 

An image is attached to show the buggy output.

 

if (mail($to, $subject, $eMessage, $headers)) {
  echo "<div align='center'>

<p><span style='font-style:italic;font-size:85%;'>
        Result summary successfully sent to [email protected].</span></p>
<p><strong>Press the button below to re-authenticate the controller and apply
your changes.</strong></p>
<form action='./re-auth.php' method='post'>
<input type='hidden' name='propertyIP' value=$propertyIP>
<input type='hidden' name='results' value=$results>
<input type='submit' value='Apply Changes'>
<p><span style='font-style:italic;font-size:85%;'>debug: value to be submitted
        is $propertyIP.</span></p>
</form>
</div>";
} else {
  echo "<br />Summary email could not be sent, please report to [email protected]";
}

 

[attachment deleted by admin]

Since you don't have single quotes around those fields html will parse them as being the end of the value as soon as a space happens.

 

Try this..

   <input type='hidden' name='propertyIP' value='$propertyIP'>
   <input type='hidden' name='results' value='$results'>

 

if that does not work then try this..

 

   <input type='hidden' name='propertyIP' value=\"$propertyIP\">
   <input type='hidden' name='results' value=\"$results\">

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.