prime Posted May 7, 2007 Share Posted May 7, 2007 Hi have the following peice of code in a form handling php script I have, Not exactly sure whats going on with it, any help would be appreciated thank you <?php $badname = array("example1"); ?> <?php if ($rs_name == in_array($badname)) /* I've also tried using if(in_array($rs_name, $badname)) without any success */ { echo "<br/><br/><center> <font color='orange' size='4'> This name has been Blocked from the registry submitter <br/> If you are the owner of this account <br/> Please use the contact us form to verify you are the account owner <p/> Account verification requires in-game verification </font> </center>"; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50325-solved-problems-with-form-handling-script/ Share on other sites More sharing options...
chronister Posted May 7, 2007 Share Posted May 7, 2007 <?php $badname = array('example1','testing','bob'); ?> <?php $rs_name='bob'; if (in_array($rs_name, $badname)) { echo "<br/><br/><center> <font color='orange' size='4'> This name has been Blocked from the registry submitter <br/> If you are the owner of this account <br/> Please use the contact us form to verify you are the account owner <p/> Account verification requires in-game verification </font> </center>"; exit(); } ?> This worked for me. I got the error message for all 3 items in the array. Nate Quote Link to comment https://forums.phpfreaks.com/topic/50325-solved-problems-with-form-handling-script/#findComment-247074 Share on other sites More sharing options...
prime Posted May 7, 2007 Author Share Posted May 7, 2007 the problem I'm having though is the $rs_name variable is collected from a form field, and basically I wanted it checked against the list of bad name entries to see if the error message should be run Quote Link to comment https://forums.phpfreaks.com/topic/50325-solved-problems-with-form-handling-script/#findComment-247076 Share on other sites More sharing options...
chronister Posted May 7, 2007 Share Posted May 7, 2007 Look at your form method. It is either post or get. then just create the variable for it. <?php $badname = array('example1','testing','bob'); ?> <?php // only use one of the following, as one will work, and one will fail. $rs_name=$_POST['name_of_field']; $rs_name=$_GET['name_of_field']; if (in_array($rs_name, $badname)) { echo "<br/><br/><center> <font color='orange' size='4'> This name has been Blocked from the registry submitter <br/> If you are the owner of this account <br/> Please use the contact us form to verify you are the account owner <p/> Account verification requires in-game verification </font> </center>"; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50325-solved-problems-with-form-handling-script/#findComment-247078 Share on other sites More sharing options...
prime Posted May 7, 2007 Author Share Posted May 7, 2007 Thank you very much its working now sigh I'm new to php and I forgot the post variable Quote Link to comment https://forums.phpfreaks.com/topic/50325-solved-problems-with-form-handling-script/#findComment-247083 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.