PHP Problem

Discussion in 'PHP' started by Darkhodge, Aug 1, 2006.

  1. #1
    Hey,

    I've created a script that sends a confirmation e-mail to the user who has just registered. It send them a link that they can click to activate their account (the norm).

    The link should be like this: "http://siteURL.com/activate.php?userName=$userName&activate=$activate".

    However for some reason it seems to add a "%0A", which is the url encoded version of ":" (if I'm correct) in the middle of the code (just before $userName) so that the link doesn't work.

    The code uses the mail() function. The message I'm sending is stored in $message and the part that's causing the problems is this:

    
    ...code exists above this...
    
    $message .= '<li><b>Automated</b> - Just click <a href="http://www.siteURL.com/activate.php?userName=';
    
    $message .= $userName . '&activate=' . $activate;
    
    ...etc...
    
    PHP:
    Is there a blatent error I've made there??? Coz I sure don't see it...
     
    Darkhodge, Aug 1, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That code is fine. Why split it up though? I'd keep building the link until it's done, then continue building the message, to avoid anomalies.
     
    T0PS3O, Aug 1, 2006 IP
  3. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #3
    What do you mean split it up? The fact that I have 2 "$message .="? I actually don't know why I did that... :eek:

    Anyway thanks for checking the code out. I managed to fix the problem by playing around a little. :D

    I still don't understand why the above method caused problems though...
     
    Darkhodge, Aug 1, 2006 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah, that's what I meant. It's fine chopping it up in readable chunks but I'd do so at 'logical' stages, not half-way building a link because it can cause loosing sight of things.

    Glad it magically disappeared again.
     
    T0PS3O, Aug 1, 2006 IP
  5. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #5
    I see where you're coming from and I'll keep it in mind in the future :)

    Anyway yeah I'm glad the random "%0A" disappeared too :D
     
    Darkhodge, Aug 1, 2006 IP
  6. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi there,
    Just wanted to say that the %0A is actually the URL Encoded form of the Line Feed (LF or the \r ) character and not ':'. So maybe you were not trimming your input data properly before using them .
    
    $blah = trim($blih);
    
    PHP:
    Just my 2c :D
    Thomas
     
    coderlinks, Aug 1, 2006 IP
  7. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #7
    Ah rite - thanks for telling me :D
     
    Darkhodge, Aug 1, 2006 IP