How do I display PHP code in HTML?
If you have individual
For example, in your
index.php (or wherever you specify your layout), you'd do something like this:
You could then use
This method also lets you pass other than just simple integer values, as
<form name="add" method="post"> <p>Age:</p> <select name="age"> <option value="1_sre">23</option> <option value="2_sam">24</option> <option value="5_john">25</option> </select> <input type="submit" name="submit"/> </form>
You will have the selected value in
1_sre. Then you will be able to split the value and get the
$stud = explode("_",$_POST['age']); $stud_id = $stud; $stud_name = $stud;
The usual workflow:
- Grab the source generated by the RTE and filter it through HTML Purifier before saving to the database.
- Escape the existing HTML:
<div id="myHtml" style="display: none"><?php echo htmlentities($html); ?></div>
You can also load the HTML content via AJAX.
In order to get your variables into the message, if you are using double quotes, you should just be able to include the variable in the string:
$message = " <html> ... <tr> <td>$name</td> </tr> ... </html> ";
You can also break out of the string
$message = " <html> ... <tr> <td>".$name."</td> </tr> ... </html> ";
Which will work with single or double quotes (personally I prefer this method with single quotes).
However when you receive this email, you will see the raw html. In order to have the html displayed properly you will need to set the appropriate mail headers. There are examples of how to do this here and here
or change the file extension to phps