March 21, 201313 yr 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!!
March 21, 201313 yr 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?
March 21, 201313 yr 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 March 21, 201313 yr by andy9l [code] tags
March 21, 201313 yr Author That's HTML 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. functions.php
March 21, 201313 yr Author Give this a shot... functions.php Oh you Awesome Person!!! worked like a charm! so what did you do mate?
March 21, 201313 yr 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 March 21, 201313 yr by andy9l Code tags are screwing up?!
March 21, 201313 yr 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
March 21, 201313 yr 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 March 21, 201313 yr by andy9l
Create an account or sign in to comment