• PHP Help
  • Link Not Clickable in Verification Email

Looks like you just want to turn it into an <a> element:

$output = '<div>Thanks for registering with localhost. Please click this link to complete this registation <br><a href="'.$url.'">displayed link text here</a></div>';

(substituting whatever you want to actually display in place of "displayed link text here". 😉 )

    PS: Or maybe better text-wise...

    $output = '<div>Thanks for registering with localhost. Please <a href="'.$url.'">click this link</a> to complete this registation</div>';
    

      Doesn't work, I'm afraid. Something to do with the 'token' that's generated during registration, it makes the url different from a regular 'webpage location' link.

      The whole page is rendered empty! Even if you right-click to view source - nothing.

      I don't know how debugging works but have been told to use 'die()' in the code to indicate where errors occur....

      You may be able to get some useful debug info by adding the following at the beginning of the file:

      <?php
      ini_set('display_errors', true); // change to false in production
      error_reporting(E_ALL);
      

      If you want to temporarily look at something at some point in the script:

      // something you do:
      $foo = some_function_or_whatever($bar);
      // see what happened:
      die("<pre>FOO:\n".var_export($foo, true)."</pre>");
      

        chome4 Doesn't work, I'm afraid. Something to do with the 'token' that's generated during registration, it makes the url different from a regular 'webpage location' link.

        Are you saying that the link becomes clickable if the token is left out (even if registration fails because of the missing token)?

          Good question. I'm new to php. The token seems to be all-important as it's part of the registration process and is used to add the user to the database for authentication - I think.

          The fact that the link IS clickable if you specify a gmail address in the form seems to point to the yahoo/hotmail side of things. Like I said, I'm new to this and this issue seems like and advanced one.

          Here's a link to form so you can try it with any email to see the end result.

          https://gmjones.org/property7/register/index.php

          ps....the link leads to nowhere....for now!

            Well I do see the email link and it looks like the IP address and domain name have both been stuffed into the hostname part of the URL instead of just the domain name.

            The mail interface I've got doesn't do a source view and isn't rendering any HTML so I don't know if that's there, but it reads:

            Subject: Register confirmation
            Thanks for registering with localhost. Please click this link to complete this registation
            https://[ip elided][domain name elided]/property7/register/verify.php?id=32&token=692f4a795f36e4289fd2626f6dca152c

            As per the line $url = 'https://**.**.***.***'.$_SERVER['SERVER_NAME'].'/property7/register/verify.php?id='.$lastId.'&token='.$token; where I'm guessing the **** bit is an IP address.

              OK, I see.

              That's what comes of getting the original from a youtube video in order to learn stuff!

              I'll see what I can do with the url later on....

              I've cleared the dabase of emails. I'll update here later.

              Thanks to you both for your help so far.

                I've changed
                $url = 'https://80.82.116.160'.$_SERVER['SERVER_NAME'].'/property7/register/verify.php?id='.$lastId.'&token='.$token;

                to
                $url = 'https://80.82.116.160/property7/register/verify.php?id='.$lastId.'&token='.$token;

                Still with the same effect. At least I didn't get any php errors.

                The 'verify.php' page was taken from here:

                <?php
                $conn = mysqli_connect("localhost","root","","registration");
                //if(isset($_POST['login'])){
                $id = $_GET['id'];
                $token = $_GET['token'];
                $select = "UPDATE register SET status = 'Active' WHERE id = '$id' AND token = '$token'";
                $result = mysqli_query($conn,$select);
                if ($result) {
                echo "verify successful. you can log in now";
                }else{
                echo "verify faild";
                }
                //}
                ?>

                Worth mentioning that my gmail account is added to my mail.yahoo.com page and the link doesn't work if the gmail account is opened via yahoo mail but works when I go to the dedicated gmail web page.

                  a month later

                  When facing these sorts of issues, keep in mind that some MUAs (Mail Clients, and I'm glaring at YOU, Outlook) automatically parse URLs into clickable links. So confusion about why you have a clickable link in some MUA and not in some others is usually because you didn't create a clickable link, but your mail software did.

                    Write a Reply...