Jump to content

$_SERVER['SERVER_NAME'] issue


Bogey
 Share

Recommended Posts

Hey hey, This is going on:1.) a user fills in a form to make an account on my website;2.) temp account is made, and confirmation mail is send to user;3.) user clicks link in confirmation mail, to activate account. This all works PERFECTBUT....!!!! This is a piece of code from them confirmation.php: (calling when activationlink in confirmation mail is clicked)

<P align='center'>Bla bla bla is send to <?php echo $row['email'];?> <BR />also check your spam-box, for the mail!<BR /> <BR />click <A href=<?php echo $_SERVER['SERVER_NAME'];?>>here</A> to go back to homepage of website</P>

the email adres in showing OK!the link is NOT!!!!Link looks like this: www.mywebsite.nl/modules/moduleX/www.mywebsite.nlinstead of this:www.mywebsite.nl Hope I made myself clear?Anyone knows why/how $_SERVER['SERVER_NAME'] adds the directory of confirmation.php in front of the servername?Or has it something to do with de href part? Thanx in advance ;)

Edited by Bogey
Link to comment
Share on other sites

The protocol is HTTP. If the URL in a link does not include the protocol then the browser assumes it is a relative link. If you have a page at http://www.domain.com/page.html, and that page has a link like this: <a href="page2.html"> There is no protocol there, so the browser assumes it is a relative link and that it points to http://www.domain.com/page2.html. Likewise, if the link has this: <a href="www.google.com"> Again, no protocol, so the browser assumes it is pointing to http://www.domain.com/www.google.com. If you want an absolute link then it needs to be fully-qualified, which means you need to include the protocol.

Link to comment
Share on other sites

Ok, got it working! ;) thnx thnx thnxt...!!!!

<?php$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')=== FALSE ? 'http' : 'https';$host = $_SERVER['HTTP_HOST'];$website = $protocol . '://' . $host;?>

Link to comment
Share on other sites

One more thing! How do I pass a emailadress by mail as a string?In the info mail towards the user, there is the loginname and password... The loginname I would like to been shown as text in the mail, but now I only get it, that the mailadress is a clickable link... this pieces of code I tried, but none worked

$email=$row['email'];$email1 = strval($email);$email2 = (string)$email;$email3 = settype($email, 'string');

All of above give a clickable link, except the last one, this gives a '1'...How do I get just a plain text?!?!?!

Edited by Bogey
Link to comment
Share on other sites

what does echo $row['email'] prints?

Link to comment
Share on other sites

The mail client makes it a link automatically. You can't control how mail clients use your email. You can add a content-type header to set the email to be a plain text email, but the mail client can ignore that if it wants to.
Hmzzz.... bummer....! :SThanx again anyway ;)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...