Jump to content

How to do this without splitting the variable into multiples?


TeddyKiller

Recommended Posts

I've got a form validation for a resend. (Problem exists in other forms too..)

//Is form submitted?
if(isset($_POST['resend'])){
    //Initialise new class
    $email = clean($_POST['email'],1,1,2);
    $user_resend = new resend($email);
    //Are there empty fields?
    if($user_resend->isFilled()) {
        //Get user info and check for rows
        if($userinfo = $user_resend->getUserInfo()) {
            //Is user inactive?
            if($user_resend->notActive()) {
                //Sending the message
                if(send_mail($email, 'Registration Confirmation', 'Administrator', $mail['resend'])) {
                    echo '<span style=\"color:#e11919;\">The validation email was successfully sent.</span>';
                } else { $error = $diserror['processing']; }
            } else { $error = $diserror['isactive']; }
        } else { $error = $diserror['emailunfound']; }
    } else { $error = $diserror['empty']; }
}

The problem is around here..

if(send_mail($email, 'Registration Confirmation', 'Administrator', $mail['resend']))

It works.. but the problem is that $mail['resend'] is defined in an language file, which .. is included into the settings at the top of the page.

This works, but within $mail['resend'] is more variables..

# Resend activation    
$mail['resend'] = 'Hello ' . $userinfo->username . '<br />' .
                'As per your request, we have sent you a new activation email.<br />' .
                'To activate your account, please click the link below:<br /><br />' .
                '<a href="http://www.horble.com/activate.php?id=' . $userinfo->actkey . '">http://www.horble.com/activate.php</a>';

The variables are defined by the function inside the validation

$userinfo = $user_resend->getUserInfo()

This bit works.. but it doesn't pass the values to $mail['resend']

 

I can fix this .. by having multiple variables.. although this could be a bit of a waste of code if it can be prevented otherwise.

 

Any ideas?

Use this:

 

# Resend activation    
$mail['resend'] = 'Hello %s<br />' .
                'As per your request, we have sent you a new activation email.<br />' .
                'To activate your account, please click the link below:<br /><br />' .
                '<a href="http://www.horble.com/activate.php?id=%d">http://www.horble.com/activate.php</a>';

 

Then before you use $mail['resend'] in that if statement, use this:

$mail['resend'] = sprintf($mail['resend'], $userinfo->username, $userinfo->actkey);

Just tried it out, it seems to work. Although the actkeys. Or %d

124927b6d336652d55b5d7a6d5837fcd5d3093d7

is an example actkey, and it displays 124927 only.. I assume its because the letter blocks it.

So I put in %s and it likes it.[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.