dtommy79 Posted June 12, 2016 Share Posted June 12, 2016 Hi, I'm trying to add php code into my URL. I have the following code: <div class="btn-group" style="padding-left: 20px;" role="group"> <a href="<?php echo $_SERVER['HTTP_HOST']; ?>/09php/html_forms.php"><button type="button" class="btn btn-default">Go back to the form</button></a> </div> The link should take me to: http://localhost:8080/09php/html_forms.php The URL is correct, but the browser cannot access it. What am I doing wrong? Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted June 12, 2016 Share Posted June 12, 2016 The reason it's not working is because you forgot to prepend a protocol to the URL: http://<?php echo $_SERVER['HTTP_HOST']; ?>/09php/html_forms.php There are some things that should be fixed:1. You shouldn't have a button inside a link, just put the class name on the link itself2. You actually don't need $_SERVER['HTTP_HOST'] because you can make a link relative to the site root just by prepending a slash. <a href="/09php/html_forms.php" class="btn btn-default">Go back to the form</a> 1 Link to comment Share on other sites More sharing options...
dtommy79 Posted June 12, 2016 Author Share Posted June 12, 2016 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now