0

Using this example, Add php variable inside echo statement as href link address?,

I am able to grab an email address from my SQL DB and make it clickable in my form. The HTML looks like this:

Contact: [email protected]

but when I either hover over if or click it, it adds the name of my domain before it. So clicking the above tries to go to:

http://mydomainname.com/[email protected]

Here is some of the code that generates my link

            while($row=mysql_fetch_array($result, MYSQL_ASSOC))
            {
                ob_start();

                echo "
....

<div class='eventContact'>Contact: <a href='".$tempcontact."'>$tempcontact</a></br></div>
                ";

                ob_end_clean();
            }   

I am guessing it shouldn't be a 'a href' but not sure what it should be.

3
  • change it to mailto: [email protected] -this will fire the users email client Commented Jun 4, 2016 at 16:58
  • <div class='eventContact'>Contact: <mailto(".$tempcontact."'.);''>$tempcontact</br></div> Commented Jun 4, 2016 at 17:01
  • What will make it clickable? Commented Jun 4, 2016 at 17:01

1 Answer 1

0

As I said in the comment:

Change it to mailto:[email protected] -this will fire the users email client

<a href="mailto:[email protected]">Email me</a>

You can then set the subject of the email too if you want

<a href="mailto:[email protected]?Subject=Hi">Email me</a>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, works now - for anyone else trying to do this I will post the end result:<div class='eventContact'>Contact: <a href='mailto:".$tempcontact.";'>$tempcontact</a></br></div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.