I'm trying to use PHP to set the value of a text box, and I tried the solution in this question:
Can HTML be embedded inside PHP "if" statement?
Here is what I'm doing:
<?php if(isset($_SESSION['date']) : ?>
<div class="label">Service Date:</div> <input type="text" class="service_date" name="service_date" value="<?php echo $_SESSION['date']?>"/>
<?php else : ?>
<div class="label">Service Date:</div> <input type="text" class="service_date" name="service_date" value="<?php echo $_SESSION['date']?>"/>
<?php endif;?>
But this isn't working for me. I know that the <?php echo $_SESSION['date']?>
is valid and working, because I inserted this at the beginning of the form, and it displayed the expected data. Can someone please tell me what I'm doing wrong here?
To be clear when I say it isn't working, there is NO data being rendered on the page. You can't see ANY HTML. When I remove the above code, all the HTML fields are displayed as expected.