The following code is for a template that handles the forgot password section of our website. (Please don't berate me for it's stupidity, I didn't write it) What I need to do is embed '/inc/forgot_password_form' with a message of 'Your PID must be numeric' if the $_POST['PID'] has non numeric chars. How would I modify this code to do that?
I know I can do it client-side using my jQuery validator but I'd rather do it here because I can also check a minimum value and show a special message for it.
{if segment_2 == 'submit'}
<?
$embed_params = 'EmailAddress="' . $_POST['EmailAddress'] . '" PID="' . $_POST['PID'] . '" ';
?>
{embed='/inc/forgot_password_form' message='{exp:forgot_password:send_email code="{segment_3}" <?=$embed_params?>}' <?=$embed_params?>}
{if:elseif segment_2 == 'reset'}
{embed='/inc/forgot_password_reset' email='{exp:forgot_password:check_code code="{segment_3}" }' code="{segment_3}"}
{if:elseif segment_2 == 'reset_submit'}
{embed='/inc/forgot_password_reset' message='{exp:forgot_password:update_password code="<?=$_POST['code']?>" password="<?=$_POST['password']?>" }' }
{if:else}
{embed='/inc/forgot_password_form' }
{/if}
Edit with new code:
So you are saying to do it like this?
{if segment_2 == 'submit'}
<?
$embed_params = 'EmailAddress="' . $_POST['EmailAddress'] . '" PID="' . $_POST['PID'] . '" ';
if (!is_int($_POST['PID']) {
{embed='/inc/forgot_password_form' message='You submitted an invalid Member #.' <?=$embed_params?>}
} else {
{embed='/inc/forgot_password_form' message='{exp:forgot_password:send_email code="{segment_3}" <?=$embed_params?>}' <?=$embed_params?>}
}
?>
{if:elseif segment_2 == 'reset'}
{embed='/inc/forgot_password_reset' email='{exp:forgot_password:check_code code="{segment_3}" }' code="{segment_3}"}
{if:elseif segment_2 == 'reset_submit'}
{embed='/inc/forgot_password_reset' message='{exp:forgot_password:update_password code="<?=$_POST['code']?>" password="<?=$_POST['password']?>" }' }
{if:else}
{embed='/inc/forgot_password_form' }
{/if}