PHP Bug in Form Code?

htp44 23 Feb, 2010
Hi,

when I'm handing over a variable via URL (like http.....?kid=100) the code works perfectly:

    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_1" name="vorname" type="text" value ="<? echo $_GET['kid']; ?>" />


But, when I try to use the same variable in the same form in an image tag like this:

<img src="http://www...../pics/<? echo $_GET['kid']; ?>.jpg" />


I only get this result (no image, just the rest of the tag)

Output

.jpg" />



It's really strange for me, because I just inserted the same php code in another html tag. Besides, it doesn't matter if I use <?php oder just <?

Then I did another test and this time the whole form doesn't show up:

<img src="http://www......./pics/<? echo "test.jpg"; ?> />


Output:

nothing at all



Is there a bug or is it me?

Thanks in advance,
Frank
GreyHead 23 Feb, 2010
Hi Frank,

Not seen this before but I suspect that the problem is the / before the PHP tags - this may act to escape the <

Try this:
<img src="<?php echo http://www...../pics/".$_GET['kid'].".jpg" ?> />


Bob

PS you can use <?, <?php or <?= here and any of them should work OK. I pretty much always use the full version of the tag for clarity and consistency.
htp44 27 Feb, 2010
Thanks Bob,

it doesn't work. The form doesn't show up. I tried also some other code without an img or " and it also doesn't work. But on the other hand this code works without a problem:

    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_1" name="kid" type="text" value ="<? echo substr($_GET['id'], -11); ?>" />


Did you try your own img code in a form?

Regards,
Frank
GreyHead 28 Feb, 2010
Hi Frank,

Did you try your own img code in a form?

I didn't test the amendment to your code that I posted - I'm afraid that if I did for every snippet I would rarely answer anything here.

Fortunately they work more often than not. In this case a few fixes are required, and this version works OK:
<img src='<?php echo "{my_domain}/images/stories/".$_GET['kid'].".jpg"; ?>' />



Bob
ve6sar 15 Apr, 2010
I'm having a similar error.
Here's my code in the Form HTML

<div class="form_item">
  <div class="form_element cf_heading">
    <h2 class="cf_text">
   <p> Please fill in this form. If you worked this day the Start, End, and   Hours worked must be filled out.</p> 
<p></p>
<p>Thanks</p>
 </h2>
  </div>
  <div class="cfclear"> </div>
</div>

<?php echo $usr_name."<br>"; ?> #For Testing
<input type="hidden" name="Name" value="<?php echo $usr_name; ?>" />

  <div class="cfclear"> </div>
</div>

<?php echo $WD; ?> # For Testing
<input id="hidden_1" name="Date" type="hidden" value="<?php echo $WD; ?>" />



And the resulting html looks like this when the form is run.
<div class="form_item"> 
  <div class="form_element cf_heading"> 
    <h2 class="cf_text"> 
   <p> Please fill in this form. If you worked this day the Start, End, and   Hours worked must be filled out.</p> 
<p></p> 
<p>Thanks</p> 
 </h2> 
  </div> 
  <div class="cfclear"> </div> 
</div> 
 
<br><input type="hidden" name="Name" value="" /> 
 
  <div class="cfclear"> </div> 
</div> 
 
<input id="hidden_1" name="Date" type="hidden" value="" />  


Yet this is the output is
[attachment=0]formerror.jpg[/attachment]

Where you see Joe Pilot and APR 02 2010 is were my testing code is outputting.
I'm using the latest stable release of Chrono Forms. ChronoForms_V3.1_RC5.5.zip
Any ideas?

Sean
GreyHead 16 Apr, 2010
Hi Sean,

That looks fine - neither $usr_name nor $WD have values so they show up as blanks.

I have no idea where the 'Joe Pilot' comes from - there is nothing in your Form HTML to show it.

Bob
htp44 22 Aug, 2010
Hello,

Did you try your own img code in a form?



I didn't test the amendment to your code that I posted - I'm afraid that if I did for every snippet I would rarely answer anything here.



I'm sorry Bob. I just realized that I didn't answer your last statement and furthermore my question could have sounded quite rude. But I just wondered back then if you did get the same mistake. That's what happended if you're in a hurry.😉

Best regards and thanks for your great support,
Frank
GreyHead 22 Aug, 2010
Hi Frank,

Thanks, no problem.

Bob
This topic is locked and no more replies can be posted.