revivalx — 2010-06-24T07:11:40-04:00 — #1
How to put $SERVER['HTTPHOST'] in href tag?
scallioxtx — 2010-06-24T07:21:41-04:00 — #2
You mean <a href="<?php echo $SERVER['HTTPHOST']; ?>"> ?
starlion — 2010-06-24T08:05:36-04:00 — #3
Not to mention that if you're trying to make a generic package, HTTP_HOST will contain the domain name, but not any subfolders the script may be hiding in.
EG: I install your script into http://www.example.com/testscript/admin.php
<a href="http://<?php echo $SERVER['HTTPHOST']; ?>/admin.php">Admin</a> is going to point to http://www.example.com/admin.php, not the URL expected.
scallioxtx — 2010-06-24T07:30:54-04:00 — #4
I'm guessing you want a link to an absolute URL, am I right?
In that case it would be
<a href="http://<?php echo $SERVER['HTTPHOST']; ?>/admin.php">Admin</a>
That is, you need to prepend "http://", and there's no need to let PHP handle "http://" and "/admin.php" as well
salathe — 2010-06-24T07:31:19-04:00 — #5
Also remember that the value in $SERVER['HTTPHOST'] (if there is one!) is user input, just like any $GET/$POST values. You'll need to properly sanitize/validate/escape its value.
revivalx — 2010-06-24T07:25:15-04:00 — #6
i mean like that, that method is really works? for sure?
can I do like this
<a href="<?php echo $SERVER['HTTPHOST'] . "/admin.php" ; ?>">Admin</a>
revivalx — 2010-06-24T09:15:53-04:00 — #7