Jump to content

PC Nerd

Members
  • Posts

    1,122
  • Joined

  • Last visited

    Never

Everything posted by PC Nerd

  1. Update: ive added this at the beginning of the loop: if($field == "L_Name") {echo "ok - value working :: ".$field."<br>";} and i change the "L_Name" to whatever value i want - and it all works... thsi puts the problem down the the if()'s.... if one is workig in dividually - shouldnt multiple conditions in it - seperated by || work? ie: if: if(condition1) {} if(condition2) {} if(condition3) {} if(condition4) {} then shouldnt: if(condition1 || condition2 || condition3 || condition4) {} ? Thanks
  2. posting?? here is an over view of how the script runs: if(isser($_GET['validate')) ## checks to see if form is submitted and set to validate it.... then validate by: looping through$_POST ( how i sent the data from teh form); i get teh $field and $value out of that $_POST array - and then check to see if $field is F_Name, L_Name, EMAIL etc etc.(THIS IS WHERE THE ERROR IS) thisis basicalyl to shortcut agains validating the same thing.... ie F_Nane, EMG_Contact etc etc all have the same validation proccesses (same regex etc). once it matches the field - it validates if $value is empty- or too long, too short - invalid data(regex) etc. then is sets the $ERROR array to include a value for that $field if there is an error ** it writes over the previous error for that field ** $ERROR is in the format of: $ERROR[fieldname] = error_type eg $ERROR['F_Name'] = 'invalid'; ( auto messages are creted for different error types ;ater in the script). the script goes on to either submit to MYSQL if there were no errors, or redisplay the form if there were - and display error messages. *** the error im receiveing is not a PHP error as such - its a code flow. what shoudl happpen is $field shoudl match one of the if(statements from teh foreach loop - however it is not.) i could possilby create a flow chart if that woudl be easier to understadn ( i knwo that this is slightly confusing even for me on accaision so let me knwo if you want me to rewrite it or something etc). Thanks for your help so far.... - im looking into teng84's code atm - ill let you knwo how that goes. EDIT: that code simply does the same thing does it not - it just does it in a different order to how im doing it (i know i shoudl do it this way but ill rewriting it later) - how coudl this solve the problem - coudl you explain what its meant to do different? Thanks END EDIT Thanks for all your help so far.
  3. ok- firslty ive tried redarrows code - exactly the same...... my expected output - is to have the $ERRORS array contain more than the "Save" Value I know that the $field isnt matching because it never reaches the echoo "got to names"; line straight after. if the ereg or preg_match isnt workign then it should either return an error for that function - or return false when i want it to return true (justu go !preg_match() to solve that etc etc). my problem is no the regular expressions used to validate - its matching the $field variable to the values of "F_Name" etc etc. Thanks
  4. ok- sorry ive chanegd teh link- wrong domain... apologies. Thanks
  5. ok- its a basic signup script - il upload a copy of the output for you in a second as for the required fields - all are required, except username and password - they are only required if the "save" radio button is checked. my script iss attached above - however that isnt the one with teh updated preg_match expressions updates. the script output is available for viewing - http://www.battleages2.com/new_user.php Thanks for all your help.
  6. ok - im not goign to code it for you here - but this is the basics: loop through database records and make your table wiht checkboxes from the $_POST data or however you send the data - you need to check which fields are ticked ( boolean values if im not mistaken) - and then compile an array of emails from those checked boxes. **this is not he best way to do it - however for a small list this would work. larger lists youl have to look at other email sending functions - not just mail(); ** loop through the final array of people to send emails to. have a vairbale that stores the email - and if you want the names and things personalised for each email - it probably requires a mysql_query eariler in the script. simply use the mail() function to send a copy of that email for you. :> Good luck
  7. No - shoudl I i had a value in my $_POST array i think that was field= 1 value = NULL. That is probably the submit button?? Ive created an increment through the foreach - that when it reaches 14 ( the number of fileds in the form) - it break;'s the loop. as i said before- should i have the submit button in the loop? Thanks
  8. not sure about teng84's suggestion - and i dont know that function - however you coudl always search for a ? and / - which usually finds the end of teh domain name and begining of directories or GET info - all you would have o do is split the string at that point - and compare the first section to your own domain name. you may als owant to addin different features - so that a person can add: domain.com/..... AND www.domain.com/... AND http://www.domain.com/... - then validate those different inputs - using roughyl the same method good luck
  9. ok - ive changed that however my original problen is still there. The foreach defiend $field - wont match with any of the String values im comparing it to even though they appear the same with print_r($_POST) etc etc any suggestions on that *thanks for the preg_match() stuff
  10. Im not really familiar with regular expressions - ive sort of read through forums and then used different expressions from around the place to get mine. as you saying it should be: if(!preg_match([A-za\'-z], $value)) ??? if so - it still doesnt explain my original problem, statically defined values arent matching. Thanks
  11. Yeah. I know that I probably coudl have designed the validation better - and I wil lnext time. However what isnt working is $field never matches any of the values its compared to - even though ive statically defined its value. ill attach teh full file. Thanks [attachment deleted by admin]
  12. Hi, Ive got a script where it loops through all the $_POST values - using an if($field == "fieldname") {valuidate for that field;} I know that the field names are correct because they are beign echoed out correctly. However when i try and patch then to a string, it wont work. Its probably best described by the code and output.: CODE: ..... foreach($_POST as $field => $value) { #echo "Stage 1.1 <br>"; echo $field."<br>"; #if($_POST['Save'] == '---') {$ERROR['Save'] = 'empty';} if($field == "Save" && $value == "---") { $ERROR[$field] = "empty"; } if($field == "User_Name" || $field == "Password" || $field == "Conf_Password") { if($_POST['Save'] == "1") { ### Validate the Username, password and email if(empty($value)) { $ERROR = $ERROR[$field] = 'empty'; } else if(!preg_match("[A-za'-z]", $value)) { $ERROR[$field] = 'invalid'; } else if(strlen($value) > 20 || strlen($value) < 5) $ERROR[$field] = 'len'; } else if($field == "Password" && $value != $_POST['Conf_Password']) { $ERROR[$field] = 'passmtch'; } } } if($field == "F_Name" || $field == "L_Name" || $field == "User_Name" || $field == "Emg_Name" || $field == "Emg_Relation") { ### Validate the names echo "is names<br>"; if(!preg_match("[A-za-z' -]", $value)) { $ERROR[$field] = 'invalid'; } else if(strlen($value) > 20) { $ERROR[$field] = 'len'; } } if($field == "Email") { if (!preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $input_email)) { $ERROR[$field] = 'invalid'; } } if($field == "Carrier" && $value = "---") { $ERROR[$field] = 'empty'; } ..... Output: F_Name L_Name Email User_Name Password Conf_Password Cell_no Carrier DOB Address Emg_Name Emg_Phone Emg_Relation Save Stage 2 Stage 3 Array ( [F_Name] => Michael [L_Name] => => [user_Name] => [Password] => [Conf_Password] => [Cell_no] => [Carrier] => --- [DOB] => [Address] => [Emg_Name] => [Emg_Phone] => [Emg_Relation] => [save] => --- ) As you can see - the values arent matchign for the $field - and the "F_Name" etc. I think its somethign to do with the datatype of the field value - however I cant tell. Any suggestions on how this can be solved woudl be great. Thansk in advance,.
  13. **bump** any suggestions ? Thanks for all help so far
  14. thankx - ill assume thats the web accessable root - im still confused betweenthe two. (/www not /) Thanks for all your help
  15. u, - those meta tags - do those need to be on all my pages? thanks edit:: do i have to place robots.txt in the foot - or in every directory - and with that can i place different robots.txt fiels in different directories so that it will change per directory?? if a /members/ wont have robot access thnks
  16. Hi, Im looking for a way to keep my domain off google's search spiders (and preferably yahoo etc as well). Its a domain i use for presenting work and running templates trials and development tests - however its unique name causes it to appear in google when similar words are searched I know that meta tages help to categories my site and get on a spiders list - however I want to reverse that proccess. Any suggestiosn would be great. Thanks
  17. $ERROR = array(); function isErr($fieldname, $ERROR) { foreach($ERROR as $field => $value) { if($field['empty'] == $fieldname) { return 0;} } return 1; } if(isErr($field, $ERROR) == 1){ setError($field, "empty"); } Ive changed the function to accept the $ERROR argument to edit - however do i need to return ERROR - and in which case how would i store it.. etc? thanks
  18. function isErr($fieldname) { if(!isset($ERROR)) { global $ERROR; $ERROR = array(); } foreach($ERROR as $field => $value) { if($field['empty'] == $fieldname) { return 0;} } return 1; } is my new function. is that correct? Thansk for the fast reply
  19. Hi, This is my first major validation - mainly because I've started to user preg_match etc etc. Ive got most of the script working - and I know that it is catchign the errors. The problem is that I can't seem to get the errors into my $ERROR array... My script is below - and is also attached. The script stopped entering the data when i added the two functions called "issErr()" and "setError()". That part of the code is meant to stop having duplicate errors on the same field. I appreciate any help. I know that most people dont like to go through large scripts for free - but I would appreciate any pointers that may help to solve my problem. Thanks for any and all help. NOTE: there are some echo statements hat seem irelevent. I added them to find out where my script was stopping etc - so just to let you know. Thanks [attachment deleted by admin]
  20. well you have a database field for `playmusic` then you simply go: if($DB['playmusic'] == 1 && $_SESSION['playedmp3'] == 0) { PLAY MUSIC } gdlk
  21. ok - I was under teh impression that continue simply continues with the rest of the loop. i want to stop the code for the res of that loop. if it im looping through an array of numbers, to use in a isPrime() function..... eg loop: isPrime()??? if it is a prime, then break this iteration other code here then that would output: other code othercode "PRIME" other code "PRIME" etc. if you get my drift. Thanks
  22. that was somethign i was trying to do to iliminate the extra value i originally thought that the $_POST array was sending the data twice, uising the string name - and then 1..... which i thought was very wierd - i was just playing with that. Apart from that - im mainly lookingat a a was to miss an iteration of a loop. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.