Lamez Posted January 10, 2008 Share Posted January 10, 2008 I am trying to have a sign up code on my website, this will allow the user to sign up, only permitted users will have the code. Well I have been racking my brain on how to do this. I want to set the password through the php script, this is what I have so far: else{ $code = "testcode"; if ($_POST['code'] != $code {$form->setError($field, "* Invaild Code"); } } but it does not work, what am I doing wrong? User still can sign up. Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/ Share on other sites More sharing options...
mrdamien Posted January 10, 2008 Share Posted January 10, 2008 Are you getting any errors? That code is not properly formed. else{ $code = "testcode"; if ($_POST['code'] != $code) { $form->setError($field, "* Invaild Code"); } } Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435293 Share on other sites More sharing options...
Lamez Posted January 10, 2008 Author Share Posted January 10, 2008 alright I have changed up the code a bit, just variables really. but now I get the error * Code not entered here is the whole code checking: $field = "code"; //Use field name for code if(!$code || strlen($subcode = trim($code )) == 0){ $form->setError($field, "* Code not entered"); } else{ $ncode = "testcode"; if ($code != $ncode) { $form->setError($field, "* Invaild Code"); } Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435304 Share on other sites More sharing options...
interpim Posted January 10, 2008 Share Posted January 10, 2008 what do you mean? like a code sent to an email they have to re-enter to verify an email address type code? Or is this a set code that you will only give out to people you want to have access to the site? Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435308 Share on other sites More sharing options...
Lamez Posted January 10, 2008 Author Share Posted January 10, 2008 This is a code I will give out to people to use on the registration Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435309 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 That can't be the whole code checking. The variable $code is undefined. So !$code is always true. Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435335 Share on other sites More sharing options...
Lamez Posted January 10, 2008 Author Share Posted January 10, 2008 you are right, it is defined in the registration script like this: <input type="text" name="code" maxlength="50" value="<? echo $form->value("code"); ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-435520 Share on other sites More sharing options...
Lamez Posted January 11, 2008 Author Share Posted January 11, 2008 oops double post. Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-436095 Share on other sites More sharing options...
Ken2k7 Posted January 11, 2008 Share Posted January 11, 2008 So is this part of the code: $field = "code"; //Use field name for code if(!$code || strlen($subcode = trim($code )) == 0){ $form->setError($field, "* Code not entered"); } else{ $ncode = "testcode"; if ($code != $ncode) { $form->setError($field, "* Invaild Code"); } in a function? If so, can you post the entire function? Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-436098 Share on other sites More sharing options...
trq Posted January 11, 2008 Share Posted January 11, 2008 you are right, it is defined in the registration script like this: <input type="text" name="code" maxlength="50" value="<? echo $form->value("code"); ?>" /> Then it would be $_POST['code'] in the script your form posts to, not simply $code. Quote Link to comment https://forums.phpfreaks.com/topic/85311-one-password-no-mysql/#findComment-436106 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.