TeddyKiller Posted April 27, 2010 Share Posted April 27, 2010 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? Link to comment https://forums.phpfreaks.com/topic/199926-how-to-do-this-without-splitting-the-variable-into-multiples/ Share on other sites More sharing options...
Ken2k7 Posted April 27, 2010 Share Posted April 27, 2010 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); Link to comment https://forums.phpfreaks.com/topic/199926-how-to-do-this-without-splitting-the-variable-into-multiples/#findComment-1049361 Share on other sites More sharing options...
TeddyKiller Posted April 27, 2010 Author Share Posted April 27, 2010 Thank you. In your post.. you have %s and %d, I've slightly read about %s in the book I'm reading. Though wouldn't the %d be %s in your post? Link to comment https://forums.phpfreaks.com/topic/199926-how-to-do-this-without-splitting-the-variable-into-multiples/#findComment-1049372 Share on other sites More sharing options...
TeddyKiller Posted April 27, 2010 Author Share Posted April 27, 2010 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] Link to comment https://forums.phpfreaks.com/topic/199926-how-to-do-this-without-splitting-the-variable-into-multiples/#findComment-1049380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.