0
Code will not run in playground, but will on Apache web server.
Any ideas as to why this gives errors on the page? Also submit button opens new window instead of desired behavior. https://code.sololearn.com/wziw1dv0btpA/?ref=app
7 Respostas
+ 1
Good thought, but still threw errors and submit button is still broken
+ 1
You will need to check if the submit-button is set. You do this like so:
If(isset($_POST['Submit'])){
//code here...
}
For this to work, you need to set a name on the input for submit as well. This block means that the php awaits the submit-button being clicked before any php-code is executed
+ 1
Another good thought.. so I tried adding that code as in the attached file. I also tried adding:
if(isset($_POST['name'])){
as well as
if(isset($_POST['name']) && isset($_POST['submit])){
This eliminated the errors ,but submit button opens a new page instead of printing the string.
https://code.sololearn.com/wziw1dv0btpA/?ref=app
+ 1
I am really lost on this problem. Everything about the code seems fine to me, and I can't seem to find what's going wrong. It might be something with the way sololearn is compiling the code. Since it works on a web server, my best guess would be that it has something to do with sololearn and not your code.
0
It seems that you have your $name variable inside a string. Try changing it to this:
echo "Hello " . $name
0
Could it be that you are running the PHP on start? Since there isn't any input yet when the page loads?
0
Has to be. Thanks for your thoughts 😁