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

20th Jul 2019, 10:06 PM
Kevin Hoelck
Kevin Hoelck - avatar
7 Respostas
+ 1
Good thought, but still threw errors and submit button is still broken
20th Jul 2019, 10:13 PM
Kevin Hoelck
Kevin Hoelck - avatar
+ 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
20th Jul 2019, 10:25 PM
Roolin
Roolin - avatar
+ 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
20th Jul 2019, 11:09 PM
Kevin Hoelck
Kevin Hoelck - avatar
+ 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.
20th Jul 2019, 11:49 PM
Roolin
Roolin - avatar
0
It seems that you have your $name variable inside a string. Try changing it to this: echo "Hello " . $name
20th Jul 2019, 10:11 PM
Roolin
Roolin - avatar
0
Could it be that you are running the PHP on start? Since there isn't any input yet when the page loads?
20th Jul 2019, 10:14 PM
Roolin
Roolin - avatar
0
Has to be. Thanks for your thoughts 😁
21st Jul 2019, 1:58 AM
Kevin Hoelck
Kevin Hoelck - avatar