0

PHP Wrong Output

Check the codes and their output to see the problem. Please help! Main page: https://code.sololearn.com/WIrJrqimOKgj/?ref=app Problem here: https://code.sololearn.com/w0MZSt7s1vVT/?ref=app

19th Jun 2017, 7:57 PM
Andrés04_ve
Andrés04_ve - avatar
12 Antworten
+ 1
You are using the wrong playground type for the second one. You need to change it to PHP. Then there is an issue with your if statement. if(isset($_POST['user']&&isset($_POST['email']&& isset($_POST['password']) You're not closing your isset() function calls. if(isset($_POST['user'])&&isset($_POST['email'])&& isset($_POST['password'])) Then this line: echo '<p>Email sent succesfully. <a href='#' >Continue as guest</a>.</p>'; has an issue do to the quotes all being single qoutes. So it's stopping at the single quote just before the # and not seeing the rest of the code. Fix it by changing the outer quotes to double quotes: echo "<p>Email sent succesfully. <a href='#' >Continue as guest</a>.</p>"; Same goes for this line: echo '<p>Error sending email. <a href='Main1.html'>Try again</a>.</p>'; Again use double quotes to fix it: echo "<p>Error sending email. <a href='Main1.html'>Try again</a>.</p>"; And once again here: echo'<p><a href='Main1.html'>Fill all camps!</a></p>'; Use double quotes and add a space after echo: echo "<p><a href='Main1.html'>Fill all camps!</a></p>";
19th Jun 2017, 8:29 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
You have to fix the if statement error first in order to see any difference with the code below it. After fixing all those issues the code ran. Whether it does what you're expecting or not IDK.
19th Jun 2017, 8:33 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
<!DOCTYPE html> <html> <head> <title>Create Desktop</title> <style> body{ text-align: center; margin-top: 25%; background-color: #202020; color: #EEEEEE; } a{ text-decoration: none; color: #AAAAAA; } </style> </head> <body> <?php if(isset($_POST['user'])&&isset($_POST['email'])&& isset($_POST['password'])) { $email = mail($_POST['email'],'Creating Desktop','blablabla','From: Example <example@hotmail.com>'); if($email){ echo "<p>Email sent succesfully. <a href='#' >Continue as guest</a>.</p>"; } else { echo "<p>Error sending email. <a href='Main1.html'>Try again</a>.</p>"; } } else { echo "<p><a href='Main1.html'>Fill all camps!</a></p>"; } ?> </body> </html> When I run this in the PHP playground I get a "Fill all camps!" link in the output.
19th Jun 2017, 8:50 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Just the exact things that I told you about in my first post.
19th Jun 2017, 8:58 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Do you have a php server running on your pc? If not you need to download one such as Wamp(windows) or Mamp(mac) etc, install, run it and start the server before php code will run on your pc.
19th Jun 2017, 9:14 PM
ChaoticDawg
ChaoticDawg - avatar
0
I tried with single and double quotes
19th Jun 2017, 8:30 PM
Andrés04_ve
Andrés04_ve - avatar
0
it's code from my pc, there is *.php code and do the same
19th Jun 2017, 8:30 PM
Andrés04_ve
Andrés04_ve - avatar
0
Syntax fixed, wrong output continues
19th Jun 2017, 8:34 PM
Andrés04_ve
Andrés04_ve - avatar
0
as I see, the '>' prints the code,
19th Jun 2017, 8:35 PM
Andrés04_ve
Andrés04_ve - avatar
0
What did you change?
19th Jun 2017, 8:53 PM
Andrés04_ve
Andrés04_ve - avatar
0
What did you change?
19th Jun 2017, 8:53 PM
Andrés04_ve
Andrés04_ve - avatar
0
I get it on playground, but not on pc
19th Jun 2017, 9:11 PM
Andrés04_ve
Andrés04_ve - avatar