I'm trying to put an html href button inside of my php code, but when I run it, I get an error message saying "This Page Isn't Working."
<?php
echo "<button onclick="location.href='phpfile.php';">My Button</button>";
?>
I'm trying to put an html href button inside of my php code, but when I run it, I get an error message saying "This Page Isn't Working."
<?php
echo "<button onclick="location.href='phpfile.php';">My Button</button>";
?>
Either you need to escape the HTML
double quotes:
echo "<button onclick=\"location.href='phpfile.php';\">My Button</button>";
Or the Javascript single quotes:
echo '<button onclick="location.href=\'phpfile.php\';">My Button</button>';
By the way,
This Page Isn't Working.
Means a 500 error, which means your php
script does not compile. Most of the time it is due to syntax errors.