I am currently working on validating two fields in a new profile which are validated using code like this.
$file = file_get_contents(".../TLCScripts/interpac.dll?RPRLogin?FormID=0&Config=PAC&LoginID=$librarycard&PIN=$PIN");
if(strpos($file, "incorrect")) {
$access = 0;
print "Your Library Card or PIN are incorrect!";
print $access;
}
if(!strpos($file, "incorrect")) {
$access = 1;
print "Your Access Is Granted";
print $access;
}
if($access == 1) {
header("Location: SITE LOCATION");
}
else {
header("Location: SITE LOCATION");
}
I need to some how pass $librarycard and $PIN variables from the New Profile fields to this script and if the $access variable returns as 1 then the fields are valid? Any suggestions on how I can go about passing these two variables and carrying the response for validation?
Thank You in advance!
Comments
Comment #1
TapocoL commentedI may be confused with what you are doing, so feel free to respond and change the status if I don't answer your question.
All you need to do is return false inside the validation rule if their access is not granted and return true if their access is granted. Validation API helps you just create scripts to test if something is valid or not. You would use other functions of Drupal to do redirections after tests have passed.
As for the variables, you can use $form_state['values']... to grab from other fields while validating another field. Look through my help that comes with the module and other support requests to get an idea of how to do that.
Comment #2
jgoodwill01 commentedThanks Alot. I've been researching the Forms API since I made this post and I'm being to understand it a bit better. Thank you for the information on $form_state['values'] I look more into that. I think the Tutorial: Ten Step-by-Step Code Samples to Help You Quickly Learn Form API http://drupal.org/node/262422 has some pretty good examples that I can use to alter the profile edit and registration forms.
I've still yet to learn how I can set a custom authentication on certain pages to test a users profile to make sure they have there library access set to true or false before they can view that page. Any suggested reading on inserting scripts into specific pages?