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
12 ответов
+ 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>";
+ 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.
+ 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.
+ 1
Just the exact things that I told you about in my first post.
+ 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.
0
I tried with single and double quotes
0
it's code from my pc, there is *.php code and do the same
0
Syntax fixed, wrong output continues
0
as I see, the '>' prints the code,
0
What did you change?
0
What did you change?
0
I get it on playground, but not on pc