Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Email - Confirm key not working

Featured Replies

Hi All,

 

I have followed a tutorial and again I am stuck, I have set up my registration and email confirmation but when I get the email confirmation I have a link which is supposed to be clicked which in return will connect to the database and set the value from 0 to 1 to show that the user is verified. However the HTML template seems messed up, as though the link is entirely wrong. If I right click and copy the link location this is where it is trying to go to.

 

 

http://{http//www.universaltechnology.co.uk%7D/confirm.php?email={sweetzdesigns_iphone@live.co.uk}&key={98f1730abc437b76b00f520c5dd1cd20}

 

I have manually tried removing this { } and re-submitted the page however it cannot find the server :S.

 

It may be a easy fix but this is like my first attempt at PHP so its a lot to take in.

 

 

 

Thanks for any help!! :mellow:

 

 

post-54531-0-63961700-1363868589_thumb.png

Just looks like whatever string replacement method you're using is omitting the curly braces from its replacements - apart from that, it's working. What's the PHP code for the email generation?

  • Author

Just looks like whatever string replacement method you're using is omitting the curly braces from its replacements - apart from that, it's working. What's the PHP code for the email generation?

Hello,

 

sorry for the late reply this is the PHP code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]">
<html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml[/url]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>UniversalTechnology - Pre-Order</title>
</head>

<body bgcolor="#C8DAC2">
<center>
<table width="605px" cellpadding="0" cellspacing="0">

    <tr>
        <td width="605px" height="149px" valign="bottom" background="img/welcome_header.gif"></td>
    </tr>
    <tr>
        <td width="605px" height="245px" valign="top" background="img/content_bg.gif">
            <center>
                 <table width="560px" align="center">
                <tr>
                    <td>
                        <p><font face="Verdana, Geneva, sans-serif" size="-1" color="#666666">Welcome {USERNAME}!</font></p>
                        <p><font face="Verdana, Geneva, sans-serif" size="-1" color="#666666">Thank-you for creating an account                                    <p>Because you want to pre-order an item we need to verify your account</p>
                  </font></p>
                        <p><font face="Verdana, Geneva, sans-serif" size="-1" color="#666666">Please confirm your account by click the link below!</font></p>
                        <center><p>[color=#0000cd]<a href="{SITEPATH}/confirm.php?email={EMAIL}&key={KEY}" [/color]style="color: #03110A;"><font size="5" face="Verdana, Geneva, sans-serif" color="#03110A">{KEY}</font></a></p></center>
                        <p><font face="Verdana, Geneva, sans-serif" size="-1" color="#666666">If the above link is not working, please copy and paste this address [color=#0000cd]({SITEPATH}/confirm.php?email={EMAIL}&key={KEY}) into your browsers address bar.</font></p>[/color]
                    </td>
                </tr>
            </table>
            </center>
        </td>
  </tr>
    <tr>
        <td width="605px" height="119px" valign="top" background="img/footer.gif" style="padding: 0; margin: 0;">
        
            <center>
            <table width="553px" align="center" cellpadding="0" cellspacing="0" style="vertical-align: top;">
                <tr><td height="15px"></td></tr>
                <tr>
                    <td>
                    
                        <p><font face="Verdana, Geneva, sans-serif" color="#999999" size="-2">You received this e-mail because you are currently a member of UniversalTechnology.co.uk. If you think you should not have received this e-mail, please <a href="" style="color: #03110A;"><font color="#03110A">contact admin@universaltechnology.co.uk</font></a></font></p>
                    </td>
                </tr>
           </table>
            </center>
            
        
      </td>
  </tr>

</table>
</center>
</body>
</html>

Edited by andy9l
[code] tags

  • Author

That's HTML :mellow:

 

Lol, well I'll attach the Function.php as that seems to be the only thing that may influence on how the email is sent. The Above HTML was the email template hence why i assumed that this was the problem.

 

Also this is the tutorial http://net.tutsplus.com/tutorials/php/create-a-signup-form-with-email-confirmation/, it contains pretty much everything (code wise) that is used so you may be able to pull out the correct information from their and see what is causing that dodgy url link.

 

By the way, thank you for your help i do appreciate it a lot especially how its for my assignment as well. :yahoo:

functions.php

You weren't escaping special characters in your preg_replace() calls. Since it's using regular expressions to find and replace, certain characters are reserved for pattern matching. You're using curly braces, which are indeed reserved. You must escape these with a backslash, and use forward slashes to denote the start and end of a regular expression.

Near the top of your original file:

$template = preg_replace('{USERNAME}', $info['username'], $template);
$template = preg_replace('{EMAIL}', $info['email'], $template);
//etc...

Becomes:

$template = preg_replace('/\{USERNAME\}/', $info['username'], $template);
$template = preg_replace('/\{EMAIL\}/', $info['email'], $template);
//etc...

Edited by andy9l
Code tags are screwing up?!

  • Author

 

You weren't escaping special characters in your preg_replace() calls. Since it's using regular expressions to find and replace, certain characters are reserved for pattern matching. You're using curly braces, which are indeed reserved. You must escape these with a backslash, and use forward slashes to denote the start and end of a regular expression.

 

Near the top of your original file:

$template = preg_replace('{USERNAME}', $info['username'], $template);
$template = preg_replace('{EMAIL}', $info['email'], $template);
//etc...

Becomes:

$template = preg_replace('/\{USERNAME\}/', $info['username'], $template);
$template = preg_replace('/\{EMAIL\}/', $info['email'], $template);
//etc...

 

 

Thaat's fairly hard to understand at the moment, but I can see where you're coming from. I'd imagine after playing PHP more I'll start to understand it better.

 

But Thanks for the working function.php :)

I'll try again. Regular expressions rely on certain characters for pattern matching, for example:

 

preg_replace("/\d{2}/", "XX", $string);

 

That will replace all cases of 2 consecutive digits with XX, like so:

 

//Input -> Output
Hello91 -> HelloXX
He91llo -> HeXXllo
Hell9o1 -> Hell9o1
Hello9{2} -> Hello9{2}

 

So, if you wanted to use a { within the text to be replaced, you need to stop it having this "meaning". You need to stop it being used as a reserved character. That's achieved using backslash (it's called escaping):

 

preg_replace("/\d\{2\}/", "XX", $string);

 

This will output:

 

Hello91 -> Hello91
He91llo -> He91llo
Hell9o1 -> Hell9o1
Hello9{2} -> HelloXX

 

Hope that helps...a little bit. A backslash essentially means "I want to find THIS character", as opposed to "pattern match with". Urgh, it's hard to explain - regular expressions are something I still struggle with.

 

Edit: I should mention \d means any digit 0-9 inclusive.

Edited by andy9l

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.