Jump to content

Recommended Posts

I want to display text when a tick box is ticked. This I can do BUT the text i want to display has a number of php tags(<?php echo $_POST["det"]; ?>). These wont display. Is it possible? Does the 'Some text' need to be withing brackets?

 

The php is...

 

if (isset($_POST['Submit1'])) {

 

if (isset($_POST['ch1'])) {

$ch1 = $_POST['ch1'];

 

if ($ch1 = 'net') {

$ch1 = 'Some text containing php tags';

}

}

}

 

Thanks

 

Ian

Link to comment
https://forums.phpfreaks.com/topic/175402-php-within-php/
Share on other sites

@dad00 -

The < and > of the php tags look like html tag delimiters and cause the php code to be treated as a html tag.

If you literally output < and > using any method, the browser will treat them as the start and end of a html tag. You must convert them to html entities to so that they are not operated on by the bowser.

Link to comment
https://forums.phpfreaks.com/topic/175402-php-within-php/#findComment-924312
Share on other sites

@dad00 -

The < and > of the php tags look like html tag delimiters and cause the php code to be treated as a html tag.

If you literally output < and > using any method, the browser will treat them as the start and end of a html tag. You must convert them to html entities to so that they are not operated on by the bowser.

 

I want the browser to read the php within the <> tags within the other php code though. if i change to < then it will appear as <

Link to comment
https://forums.phpfreaks.com/topic/175402-php-within-php/#findComment-924321
Share on other sites

I want the browser to read the php within the <> tags

Browser's don't read php code because php is a server side scripting language.

 

Perhaps if you explained exactly what you are trying to accomplish with a real example of the code you want to use.

Link to comment
https://forums.phpfreaks.com/topic/175402-php-within-php/#findComment-924352
Share on other sites

ok heres the code i have on my php page: (on the first checkbox has been defined so far)

 

<?PHP

$ch1 = 'unchecked';

$ch2 = 'unchecked';

$ch3 = 'unchecked';

$ch4 = 'unchecked';

$ch5 = 'unchecked';

 

 

 

if (isset($_POST['Submit1'])) {

 

 

 

if (isset($_POST['ch1'])) {

$ch1 = $_POST['ch1'];

 

 

 

if ($ch1 = 'net') {

 

$ch1 = '{<UL><br>

<LI><br>

<a href=<?php echo $_POST["num"]; ?>.pdf><?php echo $_POST["det"]; ?></a><br>

</LI><br>

<UL><br>

<LI>(PDF format, <!-- #config SIZEFMT = "ABBREV" --><!--#fsize file="<?php echo $_POST["num"]; ?>.pdf"--> KB)</LI><br>

</UL><br>

</UL><br>}';

 

}

}

 

if (isset($_POST['ch2'])) {

$ch2 = $_POST['ch2'];

 

if ($ch2 = 'word') {

$ch2 = 'checked';

}

}

 

if (isset($_POST['ch3'])) {

$ch3 = $_POST['ch3'];

 

if ($ch3 = 'excel') {

$ch3 = 'checked';

}

}

 

if (isset($_POST['ch4'])) {

$ch4 = $_POST['ch4'];

 

if ($ch4 = 'web') {

$ch4 = 'checked';

}

}

 

if (isset($_POST['ch5'])) {

$ch5 = $_POST['ch5'];

 

if ($ch5 = 'php') {

$ch5 = 'checked';

}

}

}

 

?>

 

<?PHP print $ch1; ?><br>

<?PHP print $ch2; ?><br>

<?PHP print $ch3; ?><br>

<?PHP print $ch4; ?><br>

<?PHP print $ch5; ?><br>

 

-----------

and the html form

 

<FORM NAME ="form1" METHOD ="POST" ACTION ="checkBoxes.php">

 

 

 

 

<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Choose your books"><br>

 

Journal: <br>

<select name="jou">

<option value="Journal of Materials Chemistry">Journal of Materials Chemistry</option>

<option value="Soft Matter">Soft Matter</option>

<option value="Polymer Chemistry">Polymer Chemistry</option>

<option value="Nanoscale">Nanoscale</option>

<option value="Physical Chemistry Chemical Physics">PCCP</option>

<option value="CrystEngComm">CrystEngComm</option>

<option value="Dalton Transactions">Dalton</option>

<option value="Organic and Biomolecular Chemistry">OBC</option>

</select>

<br>

 

Number: <br><input type="text" name="num" /><br>

Details: <br><input type="text" name="det" /><br>

 

Crystal structure data(txt): <br><input type="text" name="dettxt" /><br>

Crystal structure data(cif): <br><input type="text" name="detcif" /><br>

 

<Input type = 'Checkbox' Name ='ch1' value ="net"

<?PHP print $ch1; ?>

>Visual Basic .NET

<P>

<Input type = 'Checkbox' Name ='ch2' value="word"

<?PHP print $ch2; ?>

>Microsoft Word

<P>

<Input type = 'Checkbox' Name ='ch3' value="excel"

<?PHP print $ch3; ?>

>Microsoft Excel<br>

<P>

<Input type = 'Checkbox' Name ='ch4' value="web"

<?PHP print $ch4; ?>

>Web Design<br>

<P>

<Input type = 'Checkbox' Name ='ch5' value="php"

<?PHP print $ch5; ?>

>PHP for the Beginner<br>

<P>

 

</FORM>

 

Link to comment
https://forums.phpfreaks.com/topic/175402-php-within-php/#findComment-924363
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.