ok So I finally decided to sit down and learn some php. It is goind much better then expected. Then the thought crossed my mind about putting html and php code in a form and sending it to process.php to output the results. As expected the html I input to the form rendered correctly. I checked out the htmlspecialchars() function on the php manual and got it working. I then tried to input some basic php code to the form to see if it rendered. It does not I tried with something simple like <?php echo '1234'; > Code (markup): . So my question is why doesn't it output to the browser? I thought I would need to use the strip_tags() function or something similar. Does it automatically strip the tags? I am running this on a local server. I just figured I would ask I did look around a little bit for the information?
For starter, the code shoule be , but I am guessing that its just the typo here. The actual problem might be where you are putting this code in the form. Are you putting this code inside the "value" of the input? Also, are you viewing this file with http:// protocal or with file:/// ?
Yes that was just a typo. I was running the file on wamp server localhost/form.php The Form The Script <?php $a= 'Just a simple test'; $userInput = $_POST["abc"]; echo "$userInput"; ?> Code (markup): I realize the question is kind of a simple basic question. I just wanted to understand what was going on as I anticipated it would display the value of the variable.
Did you enter a value on the input box and click on submit. Only then your php code will show the value of that variable.
You need to submit the form first! $_POST['abc'] would be empty in your case. Your doing it wrong. Fill in a value in in the "<input name="abc" type="text" />" and press the submit button. On the top of the page you can write "<?php echo $_POST['abc']; ?>". This would echo whatever is in the form text field.
Yes thank you for the response. I am doing it the correct way. I was trying to see if the php code could be passed through the form and then displayed. I unserstand how to display the data from the form. I was attempting to see if you could pass through a php code through the form. I already defined $a So in the form itself I tried inputting <?php echo "$a"; ?> to see if it would then display that data I am just going to have to assume that php tags are automatically stripped from the form input when submitted.
If you want $a to be displayed on the form you need to enter : $a= 'Just a simple test';<input name="abc" type="text" value ="<?php echo $a; ?>"/>