Re: [PHP] Help:Multi Page form using session variables
I meant to say that I'm on PHP 4.3.8, apache 1.3 Global Variables are on. If you read below for each form element (textbox, menu) I've set a value of value= ""> I believe that is not setting the session variable but merely grabbing the input from the user. So what I can't find out after digging through books and googling, is how / where to actually declare the variable. Seems most of the examples use a variable that is set already by the programmer, not by the user. Stuart --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: > I cant figure out if I'm doing something wrong or my > web server is: > I have a multi page form that will span 5, now I'm > just trying to get it too 3 pages working. > If I go from Page 1 direct to Page 3, then the > variables print out fine on Page 3. If I go Page 1 > then Page 2 and then to Page 3, only Page2 variables > print out on 3. > > I must be missing something ? > > > Page1: excerpt: > > session_start(); > ?> > > print "Welcome, your session ID is > ".session_id()."\n\n"; > ?> > > > action="TestMulti2.php"> >cellpadding="2" cellspacing="2"> > > Listing > Name >type="text" id="ListingName" value=" $_SESSION['ListingName']; ?>"> > > Page 2: > > session_start(); > > if ( empty( $_SESSION['l_industry'] ) ) { > $_SESSION['l_industry']=array(); > } > > if ( is_array( $_REQUEST['LurkerIndustry'] ) ) { > $_SESSION['l_industry'] = array_unique( > array_merge( $_SESSION['l_industry'], > $_REQUEST['LurkerIndustry'] ) > ); > } > if ( empty( $_SESSION['l_tterm'] ) ) { > $_SESSION['l_tterm']=array(); > } > > if ( is_array( $_REQUEST['LurkerTaxTerm'] ) ) { > $_SESSION['l_tterm'] = array_unique( > array_merge( $_SESSION['l_tterm'], > $_REQUEST['LurkerTaxTerm'] ) > ); > } > ?> > > Page 3: > > session_start(); > ?> > print "Welcome, your session ID is > ".session_id()."\n\n"; > ?> > > echo "\$ListingName = ".$ListingName.""; > echo "\$AltP1 = ".$AltP1." "; > echo "\$AltP2 = ".$AltP2." "; > echo "\$Pgr = ".$Pgr." "; > echo "\$El2 = ".$El2." "; > echo "\$El3 = ".$El3." "; > echo "\$LurkerEdu = ".$LurkerEdu.""; > echo "\$LurkerAuth = ".$LurkerAuth." "; > echo "\$LurkerExperience = ".$LurkerExperience." > "; > echo "\$LurkerLevel = ".$LurkerLevel." "; > echo "\$LurkerSecurity = ".$LurkerSecurity." "; > > echo $LurkerIndustry['0'].""; > echo $LurkerIndustry['1'].""; > echo $LurkerIndustry['2'].""; > echo $LurkerIndustry['3'].""; > echo $LurkerIndustry['4'].""; > echo $LurkerTaxTerm['0'].""; > echo $LurkerTaxTerm['1'].""; > echo $LurkerTaxTerm['2'].""; > ?> > > > Thank you > Stuart > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested foreach ?
Robby Here is the printout : Using- print_r ($skills); print_r ($skys); print_r ($slus); Array ( [0] => skillone [1] => skilltwo [2] => skillthree [3] => [4] => ) Array ( [0] => 2 [1] => 3 [2] => 4 [3] => [4] => ) Array ( [0] => [1] => [2] => [3] => [4] => ) 1 FYI - The skills is a string, skys and slus ints. Also I had only filled in 3 of the 5 for each. Thank you Stuart --- Robby Russell <[EMAIL PROTECTED]> wrote: > On Sun, 2004-10-17 at 09:53 -0700, Stuart Felenstein > wrote: > > I have 3 arrays. 3 for 3 fields in a table (all > part > > of 1 record) > > array1 - field1 > > array2 - field2 > > array3 - field3 > > > > What I've been doing which works good with one > array: > > if ( is_array( $_SESSION['foo'] ) ) { > > foreach ( $_SESSION['foo'] as $x ) { > > sql .= "INSERT INTO TABLE (... > > VALUES ($x) > > > > Just can't seem to figure out how with three > arrays. > > > > help appreciated. > > > > Stuart > > > > Can you provide a print_r() output of your > $_SESSION['foo'] ? > > I can help you more after that. > > -Robby > > -- > /*** > * Robby Russell | Owner.Developer.Geek > * PLANET ARGON | www.planetargon.com > * Portland, OR | [EMAIL PROTECTED] > * 503.351.4730 | blog.planetargon.com > * PHP/PostgreSQL Hosting & Development > / > > > ATTACHMENT part 2 application/pgp-signature name=signature.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested foreach ?
They are related in the sense that they are part of one record in the database. Fields Skill YearsUsed LastUsed When you say array of arrays you are referring to a multi-dimensional ? I'm not sure what you mean by are the [0] related. Thank you, Stuart --- Robby Russell <[EMAIL PROTECTED]> wrote: > On Sun, 2004-10-17 at 12:40 -0700, Stuart Felenstein > wrote: > > Robby > > > > Here is the printout : > > Using- > > print_r ($skills); > > print_r ($skys); > > print_r ($slus); > > > > > > Array ( [0] => skillone [1] => skilltwo [2] => > > skillthree [3] => [4] => ) Array ( [0] => 2 [1] => > 3 > > [2] => 4 [3] => [4] => ) Array ( [0] => [1] => [2] > => > > [3] => [4] => ) 1 > > > > FYI - The skills is a string, skys and slus ints. > > Also I had only filled in 3 of the 5 for each. > > > > Thank you > > Stuart > > Are these 3 arrays related somehow? are all the > [0]'s related and all > the [1]'s related in each array? > > If so, you might consider having an array of arrays > > -Robby > > -- > /*** > * Robby Russell | Owner.Developer.Geek > * PLANET ARGON | www.planetargon.com > * Portland, OR | [EMAIL PROTECTED] > * 503.351.4730 | blog.planetargon.com > * PHP/PostgreSQL Hosting & Development > / > > > ATTACHMENT part 2 application/pgp-signature name=signature.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested foreach ?
Okay, I will try - I have these three fields in a form for user input. There are 10 sets of these, i.e. Users can enter three sets of skills, with the yearsused and when last used. I have set them up as arrays, since it's probably not wise to manage 30 seperate variables. I'm using session variables: $_SESSION['skills'] = $_POST['skill']; $_SESSION['skys'] = $_POST['sky']; $_SESSION['slus'] = $_POST['slu']; My problem is I do not know how to get these into the database with one query. Hope this is clearer. Thank you , Stuart --- Robby Russell <[EMAIL PROTECTED]> wrote: > On Sun, 2004-10-17 at 13:08 -0700, Stuart Felenstein > wrote: > > They are related in the sense that they are part > of > > one record in the database. > > Fields > > Skill YearsUsed LastUsed > > > > When you say array of arrays you are referring to > a > > multi-dimensional ? I'm not sure what you mean by > > > are the [0] related. > > > > Thank you, > > Stuart > > I guess that I am just trying to figure out what > your issue is. > > Can you explain what the issue is a bit more, in > plain english and > perhaps I can help you from there. > > All I can see right now is that you are having an > issue with a nested > foreach, but didn't really explain what the issue > was. > > -Robby > > > -- > /*** > * Robby Russell | Owner.Developer.Geek > * PLANET ARGON | www.planetargon.com > * Portland, OR | [EMAIL PROTECTED] > * 503.351.4730 | blog.planetargon.com > * PHP/PostgreSQL Hosting & Development > / > > > ATTACHMENT part 2 application/pgp-signature name=signature.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested foreach ?
John, Sorry, I'm not trying to be unclear. There are 3 columns in the table. In the user form. there are 30 fields, 10 text and 20 dropdown. The 10 text are: $_SESSION['skills'] = $_POST['skill']; The first dropdown is : $_SESSION['skys'] = $_POST['sky']; The second dropdown is: $_SESSION['slus'] = $_POST['slu']; So I need to grab the input and enter into database where each set of skill, sky , slu is a new record. I hope this is clearer. Stuart --- John Holmes <[EMAIL PROTECTED]> wrote: > Stuart Felenstein wrote: > > > Here is the printout : > > Using- > > print_r ($skills); > > print_r ($skys); > > print_r ($slus); > > > > > > Array ( [0] => skillone [1] => skilltwo [2] => > > skillthree [3] => [4] => ) Array ( [0] => 2 [1] => > 3 > > [2] => 4 [3] => [4] => ) Array ( [0] => [1] => [2] > => > > [3] => [4] => ) 1 > > > > FYI - The skills is a string, skys and slus ints. > > Also I had only filled in 3 of the 5 for each. > > Since we're just guessing at what you want, I'll > guess something like this: > > foreach($skills as $key => $skill) > { >echo "$skill - {$skys[$key]} - {$slus[$key]}\n"; > } > > -- > > ---John Holmes... > > Amazon Wishlist: > www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals > www.phparch.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested foreach ?
Not working. > foreach($_SESSION['skills'] as $key => $skill) > { >$query = "INSERT INTO table (skill, sky, sku) > VALUES ('$skill', > {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; >//run query > } The foreach is generating an invalid argument. I'm just going to show again what I have set up: There are five for each of these: Then I post the session variables as: $_SESSION['skills'] = $_POST['skill']; $_SESSION['skys'] = $_POST['sky']; $_SESSION['slus'] = $_POST['slu']; It looks like the loop above is using the $skills array to advance through the other arrays ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Nested foreach ?
Wish I had better news. Warning: Invalid argument supplied for foreach() in /home/lurkkcom/public_html/TestMultiTrans2.php on line 90 INSERT INTO LurkProfiles_Skicerts (ProfileID, SkilCerts, NumYear, Lused) VALUES () line 90: foreach($skills as $key => $skill) To confirm : I changed to this: > // Doing this makes the code below easier to read > $skills = $_SESSION['skills']; > $skys = $_SESSION['skys']; > $slus = $_SESSION['slus']; >From this : I changed the $_SESSION['skills'] = $_POST['skill']; $_SESSION['skys'] = $_POST['sky']; $_SESSION['slus'] = $_POST['slu']; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Nested foreach ?
Guess what , it's working ! The key (after yours and John's iteration lines) was adding these into the script: > $skills = $_SESSION['skills']; > $skys = $_SESSION['skys']; > $slus = $_SESSION['slus']; A big thank you! to all who helped out here and for hanging in. Graham, thank you for continuing to help me on this issue. You are right about manual, and I have been reading the manual along with some PHP / MySQL books. I actually have solved a few things on my own. ;) More reading is in order! Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: [PHP-DB] Question: Putting separate form elements into an array
Sorry about the two lists. The echo's are fine. The problem was iterating through the 3 arrays. Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > Stuart, now I'm confused. > > You seem to be posting slightly different versions > of problems relating to > the same script(s) on 2 lists. > > What is the current situation? Iterating through the > 3 arrays or inserting > into MySQL? > > Graham > > > -Original Message- > > From: Stuart Felenstein > [mailto:[EMAIL PROTECTED] > > Sent: 17 October 2004 16:14 > > To: Stuart Felenstein; Graham Cossey; > [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] Question: Putting separate > form elements into an > > array > > > > > > Changed my direction somewhat but keep getting a > parse > > error and although I know where it is , I can't > seem > > to figure out what I need to do to make it syntax > > correct: > > > [snip] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help: Suggestions for multi page form validation
I have a multi-page form that ends in the last page as a transaction to mysql. In the transaction there are a number of steps, i.e. query1 = Insert into ".. run query1 query2 = Insert into ". run query 2 query3 = Insert into ".. run query 3 Then an if / else statement that checks if all queries were sucessful (commit) or else (rollback) I need to add server side validation So my thoughts are : 1- Do it on a page by page (form by form) basis, meaning user can't go past page1 if there are form error. I'm just not sure in this case where the validation would go. Since 1st page is set on submit to go to 2nd page. Would I put the validations on page/form2 and then it would print out errors directing back to form1 ? 2- Last page validation - waiting till the transaction page to do validation. Should I set this up as one block on top that checks all the submitted form values, or pepper throughout all the transactions ? Hope my question is clear and am open to any suggestions or ideas. Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help: Suggestions for multi page form validation
If it's okay I'll throw out two more questions then. 1-Probably a silly question, but is a "faux pas" if I don't do client side [javascript] validations ? 2a- Textboxes - provided I'm not allowing special characters (only alphanumeric) does this alone protect me from things like "sql injections" ? 2b- Do selects (menus, dropdowns) need to be validated for string content. aka, can crafty hackers turn these into a way to enter some funky data ? Thank you , Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > Personally I would do as you suggest in 1. I would > think your users would > get rather annoyed if they had gone through several > form pages to be told at > the end of an error in form page1. > > So, page2 validates page1 etc. I would assume that > page2 already does some > processing of page1 anyway, as I believe you are > adding the for. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help: Suggestions for multi page form validation
Yes, this is a great reminder, as I thought about it. Man, can one form be so time consuming ? :) Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > You probably also want to check > somehow that page2.php > is actually being called from page1.php and not by > any other means. > > HTH > Graham > > > -Original Message- > > From: Stuart Felenstein > [mailto:[EMAIL PROTECTED] > > Sent: 19 October 2004 10:26 > > To: Graham Cossey; [EMAIL PROTECTED] > > Subject: RE: [PHP] Help: Suggestions for multi > page form validation > > > > > > If it's okay I'll throw out two more questions > then. > > > > 1-Probably a silly question, but is a "faux pas" > if I > > don't do client side [javascript] validations ? > > > > 2a- Textboxes - provided I'm not allowing special > > characters (only alphanumeric) does this alone > protect > > me from things like "sql injections" ? > > > > 2b- Do selects (menus, dropdowns) need to be > validated > > for string content. aka, can crafty hackers turn > > these into a way to enter some funky data ? > > > > Thank you , > > Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Extracting relevant text from a text file
Best way for me to explain this is by example - I just applied for a job and cut and past my resume into a textarea. After submitting it had extracted all the information and placed them into textfields. So my first name was now in the first name textfield, city was in the city field. Also , work experience and companies were also extracted to certain areas. How sophisticted a search is this and are there functions within PHP that make this accomplishable ? I'm not entirely sure how it's done. I'm assuming searches are run looking for certain strings, name though ? is there a way to search for pronouns. Last, I guess if I had an un-average formatted resume it would not work as well. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validation problem with array.
After some back and forth posts here I had finally thought my array issue was over, but! To review I have 30 form elements on a page 10 are skill[] 10 are sky[] 10 are slu[] I pass them as session variables $_SESSION['skills'] = $_POST['skill']; $_SESSION['skys'] = $_POST['sky']; $_SESSION['slus'] = $_POST['slu']; Then when everyting is passed into a database transaction: $skills = $_SESSION['skills']; $skys = $_SESSION['skys']; $slus = $_SESSION['slus']; foreach($_SESSION['skills'] as $key => $skill) { $query = "INSERT INTO Profiles_skills (ProfileID, SkilCerts, NumYear, Lused) VALUES ($LID, '$skill', {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; //$result = mysql_query($query); Here is the problem: Using (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") . "",true,true,true,true,"",false,1); I can't seem to differentiate between the the elements because they are all labeled skill[] So basically validation isn't doing anything . I'm thinking of finding a better way to validate , or if i change the elements to skill[1], skill[2] , what would that do to my iteration loop ? Thank you, Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation problem with array.
My problem is not related to the insert or iteration. It's related to the validaton of those elements: skill[] skill[] etc. Clearer ? Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > Not sure I really know where you have the problem, > but I am assuming you are > trying to construct the INSERT statement within your > foreach loop. > > If so, why use $_POST["skill[]"] when you have > $skill which is that current > element being iterated? > Did you read the foreach doc? > http://uk2.php.net/manual/en/control-structures.foreach.php > > HTH > Graham > > > > -Original Message- > > From: Stuart Felenstein > [mailto:[EMAIL PROTECTED] > > Sent: 20 October 2004 13:35 > > To: [EMAIL PROTECTED] > > Subject: [PHP] Validation problem with array. > > > > > > After some back and forth posts here I had finally > > thought my array issue was over, but! > > > > To review I have 30 form elements on a page > > 10 are skill[] > > 10 are sky[] > > 10 are slu[] > > > > I pass them as session variables > > > > $_SESSION['skills'] = $_POST['skill']; > > $_SESSION['skys'] = $_POST['sky']; > > $_SESSION['slus'] = $_POST['slu']; > > > > Then when everyting is passed into a database > > transaction: > > > > $skills = $_SESSION['skills']; > > $skys = $_SESSION['skys']; > > $slus = $_SESSION['slus']; > > > > foreach($_SESSION['skills'] as $key => $skill) > > { > > $query = "INSERT INTO Profiles_skills (ProfileID, > > SkilCerts, NumYear, Lused) > > VALUES ($LID, '$skill', > > > {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; > > //$result = mysql_query($query); > > > > Here is the problem: > > > > Using > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") > . > > "",true,true,true,true,"",false,1); > > > > I can't seem to differentiate between the the > elements > > because they are all labeled skill[] > > So basically validation isn't doing anything . > > > > I'm thinking of finding a better way to validate , > or > > if i change the elements to skill[1], skill[2] , > what > > would that do to my iteration loop ? > > > > Thank you, > > Stuart > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: > http://www.php.net/unsub.php > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation problem with array.
Believe it or not I had just thought of doing a foreach with the validation. I'll see how it goes. Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > Maybe you would like to post your validation code > then. > > I (we) do not know where the line: > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")."",true,true,true,true,"" > ,false,1); > > is being called. > > Have you thought about using an iteration as you > have when constructing the > INSERT statement? > Have you considered placing validation within the > iteration you have when > constructing the INSERT statement? > > If you do a print_r($skills) you will see that > although in the form they are > named skill[] when passed to your script they will > be skill[0], skill[1], > skill[2]... > > Also, this line : > > foreach($_SESSION['skills'] as $key => $skill) > > could read > > foreach($skills as $key => $skill) > > as you have the line: > > $skills = $_SESSION['skills']; > > Same for skys and slus. > > Graham > > > -Original Message- > > From: Stuart Felenstein > [mailto:[EMAIL PROTECTED] > > Sent: 20 October 2004 14:06 > > To: Graham Cossey; [EMAIL PROTECTED] > > Subject: RE: [PHP] Validation problem with array. > > > > > > My problem is not related to the insert or > iteration. > > It's related to the validaton of those elements: > > skill[] > > skill[] > > etc. > > > > Clearer ? > > > > Stuart > > --- Graham Cossey <[EMAIL PROTECTED]> wrote: > > > > > Not sure I really know where you have the > problem, > > > but I am assuming you are > > > trying to construct the INSERT statement within > your > > > foreach loop. > > > > > > If so, why use $_POST["skill[]"] when you have > > > $skill which is that current > > > element being iterated? > > > Did you read the foreach doc? > > > > > > http://uk2.php.net/manual/en/control-structures.foreach.php > > > > > > HTH > > > Graham > > > > > > > > > > -Original Message- > > > > From: Stuart Felenstein > > > [mailto:[EMAIL PROTECTED] > > > > Sent: 20 October 2004 13:35 > > > > To: [EMAIL PROTECTED] > > > > Subject: [PHP] Validation problem with array. > > > > > > > > > > > > After some back and forth posts here I had > finally > > > > thought my array issue was over, but! > > > > > > > > To review I have 30 form elements on a page > > > > 10 are skill[] > > > > 10 are sky[] > > > > 10 are slu[] > > > > > > > > I pass them as session variables > > > > > > > > $_SESSION['skills'] = $_POST['skill']; > > > > $_SESSION['skys'] = $_POST['sky']; > > > > $_SESSION['slus'] = $_POST['slu']; > > > > > > > > Then when everyting is passed into a database > > > > transaction: > > > > > > > > $skills = $_SESSION['skills']; > > > > $skys = $_SESSION['skys']; > > > > $slus = $_SESSION['slus']; > > > > > > > > foreach($_SESSION['skills'] as $key => $skill) > > > > { > > > > $query = "INSERT INTO Profiles_skills > (ProfileID, > > > > SkilCerts, NumYear, Lused) > > > > VALUES ($LID, '$skill', > > > > > > > > > > {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; > > > > //$result = mysql_query($query); > > > > > > > > Here is the problem: > > > > > > > > Using > > > > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") > > > . > > > > "",true,true,true,true,"",false,1); > > > > > > > > I can't seem to differentiate between the the > > > elements > > > > because they are all labeled skill[] > > > > So basically validation isn't doing anything . > > > > > > > > I'm thinking of finding a better way to > validate , > > > or > > > > if i change the elements to skill[1], skill[2] > , > > > what > > > > would that do to my iteration loop ? > > > > > > > > Thank you, > > > > Stuart > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: > > > http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation problem with array.
Brent, Thank you , I can't do an associative because it part of a user input form. The values will be dependent on the users. I'm going to try and give each form element a index number skill[0], skill[1] since the foreach loop is doing that anyway. The reason I haven't posted the validation is because it's part of a class, so what exists in the page is only part of the code. Stuart --- Brent Baisley <[EMAIL PROTECTED]> wrote: > I think I might know what you are trying to do. You > want to have a > "name" associated with the skill (or skys or slus). > You can use an > associative array to "name" your array elements. In > your form, you can > change the array to be something like this: > skills[cooking] > skills[flying] > skills[walking] > ... > > Notice there are no quotes around the skill names. > Now each array > element has an array key that is a name. The > computer doesn't really > care, but it makes it easier for you to read your > code. And you now > have name/value pairs. You can process the array > like this: > > $skillNames = array_keys($skills); > foreach($skillNames as $skill) { > echo 'Skill: '.$skill.' Value: '.$skills[$skill].' > '; > } > > Of course, instead of echoing you would do your > validation or > substitution. > > On Oct 20, 2004, at 8:35 AM, Stuart Felenstein > wrote: > > > After some back and forth posts here I had finally > > thought my array issue was over, but! > > > > To review I have 30 form elements on a page > > 10 are skill[] > > 10 are sky[] > > 10 are slu[] > > > > I pass them as session variables > > > > $_SESSION['skills'] = $_POST['skill']; > > $_SESSION['skys'] = $_POST['sky']; > > $_SESSION['slus'] = $_POST['slu']; > > > > Then when everyting is passed into a database > > transaction: > > > > $skills = $_SESSION['skills']; > > $skys = $_SESSION['skys']; > > $slus = $_SESSION['slus']; > > > > foreach($_SESSION['skills'] as $key => $skill) > > { > > $query = "INSERT INTO Profiles_skills (ProfileID, > > SkilCerts, NumYear, Lused) > > VALUES ($LID, '$skill', > > > {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; > > //$result = mysql_query($query); > > > > Here is the problem: > > > > Using > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") > . > > "",true,true,true,true,"",false,1); > > > > I can't seem to differentiate between the the > elements > > because they are all labeled skill[] > > So basically validation isn't doing anything . > > > > I'm thinking of finding a better way to validate , > or > > if i change the elements to skill[1], skill[2] , > what > > would that do to my iteration loop ? > > > > Thank you, > > Stuart > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: > http://www.php.net/unsub.php > > > > > -- > Brent Baisley > Systems Architect > Landover Associates, Inc. > Search & Advisory Services for Advanced Technology > Environments > p: 212.759.6400/800.759.0577 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation problem with array.
Yes I just found that out :). Back to the drawing board!. Stuart --- Brent Baisley <[EMAIL PROTECTED]> wrote: > I thought you were using checkboxes based on your > true/false. So the > user is actually typing in skills? > > Not sure where you are going with skill[0], > skill[1]. You are creating > an associative array when you do that. In and input > form, skill[0] and > skill[a] are actually no different, aside from the > name you are using > for that element. > > > On Oct 20, 2004, at 9:41 AM, Stuart Felenstein > wrote: > > > Brent, > > Thank you , I can't do an associative because it > part > > of a user input form. The values will be > dependent on > > the users. I'm going to try and give each form > > element a index number skill[0], skill[1] since > the > > foreach loop is doing that anyway. > > > > The reason I haven't posted the validation is > because > > it's part of a class, so what exists in the page > is > > only part of the code. > > > > Stuart > > > > > > --- Brent Baisley <[EMAIL PROTECTED]> wrote: > > > >> I think I might know what you are trying to do. > You > >> want to have a > >> "name" associated with the skill (or skys or > slus). > >> You can use an > >> associative array to "name" your array elements. > In > >> your form, you can > >> change the array to be something like this: > >> skills[cooking] > >> skills[flying] > >> skills[walking] > >> ... > >> > >> Notice there are no quotes around the skill > names. > >> Now each array > >> element has an array key that is a name. The > >> computer doesn't really > >> care, but it makes it easier for you to read your > >> code. And you now > >> have name/value pairs. You can process the array > >> like this: > >> > >> $skillNames= array_keys($skills); > >> foreach($skillNames as $skill) { > >>echo 'Skill: '.$skill.' Value: > '.$skills[$skill].' > >> '; > >> } > >> > >> Of course, instead of echoing you would do your > >> validation or > >> substitution. > >> > >> On Oct 20, 2004, at 8:35 AM, Stuart Felenstein > >> wrote: > >> > >>> After some back and forth posts here I had > finally > >>> thought my array issue was over, but! > >>> > >>> To review I have 30 form elements on a page > >>> 10 are skill[] > >>> 10 are sky[] > >>> 10 are slu[] > >>> > >>> I pass them as session variables > >>> > >>> $_SESSION['skills'] = $_POST['skill']; > >>> $_SESSION['skys'] = $_POST['sky']; > >>> $_SESSION['slus'] = $_POST['slu']; > >>> > >>> Then when everyting is passed into a database > >>> transaction: > >>> > >>> $skills = $_SESSION['skills']; > >>> $skys = $_SESSION['skys']; > >>> $slus = $_SESSION['slus']; > >>> > >>> foreach($_SESSION['skills'] as $key => $skill) > >>> { > >>> $query = "INSERT INTO Profiles_skills > (ProfileID, > >>> SkilCerts, NumYear, Lused) > >>> VALUES ($LID, '$skill', > >>> > >> > > > {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; > >>> //$result = mysql_query($query); > >>> > >>> Here is the problem: > >>> > >>> Using > >>> > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") > >> . > >>> "",true,true,true,true,"",false,1); > >>> > >>> I can't seem to differentiate between the the > >> elements > >>> because they are all labeled skill[] > >>> So basically validation isn't doing anything . > >>> > >>> I'm thinking of finding a better way to validate > , > >> or > >>> if i change the elements to skill[1], skill[2] , > >> what > >>> would that do to my iteration loop ? > >>> > >>> Thank you, > >>> Stuart > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: > >> http://www.php.net/unsub.php > >>> > >>> > >> -- > >> Brent Baisley > >> Systems Architect > >> Landover Associates, Inc. > >> Search & Advisory Services for Advanced > Technology > >> Environments > >> p: 212.759.6400/800.759.0577 > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, visit: > http://www.php.net/unsub.php > >> > >> > > > > > -- > Brent Baisley > Systems Architect > Landover Associates, Inc. > Search & Advisory Services for Advanced Technology > Environments > p: 212.759.6400/800.759.0577 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation problem with array.
See below: --- Graham Cossey <[EMAIL PROTECTED]> wrote: > Also, this line : > foreach($_SESSION['skills'] as $key => $skill) > could read > foreach($skills as $key => $skill) > as you have the line: > $skills = $_SESSION['skills']; > Same for skys and slus. > Graham Graham, I've read this over and over and I must be dense because I"m not totally comprehending it. Let me show you how I set it all up. Remember it's a multi page form: So the form elements are: skills[], skys[], slus[] Then on the next page I have to still pass the session variables, and so: $_SESSION['skills'] = $_POST['skill']; $_SESSION['skys'] = $_POST['sky']; $_SESSION['slus'] = $_POST['slu']; Now the transcation script: $skills = $_SESSION['skills']; $skys = $_SESSION['skys']; $slus = $_SESSION['slus']; foreach($_SESSION['skills'] as $key => $skill) { $query = "INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, $LID, '$skill', {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})"; //$result = mysql_query($query); $res6 = run_query($query); echo $query; } I understand that in the insert statement I need not repeat $_SESSION. The rest though is fuzzy. It was working, now I'm getting some really odd behaviour, in that, unless i fill in every field in the form, I get a mysql syntax error. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation problem with array.
You mean why do i have $_SESSION['skills'] in the foreach ? Stuart --- Andre Dubuc <[EMAIL PROTECTED]> wrote: > Hi Stuart, > > I haven't followed your thread too closely, but I > did see something that might > be the cause of your problems: > > [snip] > > > Let me show you how I set it all up. Remember it's > a > > multi page form: > > So the form elements are: skills[], skys[], slus[] > > Then on the next page I have to still pass the > session > > variables, and so: > > > > $_SESSION['skills'] = $_POST['skill']; > > $_SESSION['skys'] = $_POST['sky']; > > $_SESSION['slus'] = $_POST['slu']; > > > > Now the transcation script: > > > > $skills = $_SESSION['skills']; > > $skys = $_SESSION['skys']; > > $slus = $_SESSION['slus']; > > > > foreach($_SESSION['skills'] as $key => $skill) > ^^ ^^ > > I'm puzzled why you reverted to $_SESSION['skills'] > when the line above you've > set $skills = $_SESSION['skills']?? > > HTH, > Andre > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation problem with array.
Graham, I'm going to make those changes. Not sure if that was creating some crazy behaviour. See inline: --- Graham Cossey <[EMAIL PROTECTED]> wrote: > > { > if ($skill != '') // Has this skill been > entered? I don't know if I care if it's been entered. My main concern would be to make sure that if a $skill was entered, then a matching $skys and $slus should be: skills[0]-baker skys[0]-7 slus[0]-2002 but wouldn't want skill[0]-baker skys[1]-7 slus[2]-2002 In other words I need to figure out how to check that each "line" is complete. But~ right now, it is matching all the values/inputs correctly. If someone just chose a slus, seems the database won't take it. > { > // You may also want to check for sky & slu > entries Not sure why I would want too: > > //$result = mysql_query($query); > > $res6 = run_query($query); > > echo $query; > ^^^ > What does this output? It outputs the insert and values string. And it seems to print the iteration: INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, 39, 'a', 2,1)INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, 39, 'b', 3,2)INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, 39, 'c', 4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, 39, 'd', 5,4)INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, 39, 'e', 6,5)your insertions were successful > }// end if ($skill != '') This probably makes sense to add , perhaps that is why if I don't use all the elements for input I get a syntax error. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation problem with array.
See inline: --- Graham Cossey <[EMAIL PROTECTED]> wrote: > > In other words I need to figure out how to check > > that each "line" is complete. right now, it is > > matching all the values/inputs correctly. If > > someone just chose a slus, seems the database > But is this due to the sql statement being rejected > as opposed to being > caught by your validation? What validation :) . I haven't added that in yet,due to figuring out why the insertions weren't taking. > > > { > > > // You may also want to check for sky & > > > slu entries > > > You would want to because of the paragraph above > > > about "My main concern..." Right now I have this [right below]: If I want to check for skys and slus, I add another set of braces with if($sky != '' ... and below "end if ($sky != '') > foreach($skills as $key => $skill) { if ($skill != '' && $skys[$key] != '' && $slus[$key] != '') { $query = "INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID, SkilCerts, NumYear, Lused) VALUES (null, $LID, '$skill', $skys[$key],$slus[$key])"; $res6 = run_query($query); echo "Query $key = $query "; } end if ($skill != '') } Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: Validation on select boxes and lists.
Hope this is not off topic, and it might be a dumb question, but I'm new. For drop down menus, list boxes, selects etc, would validation be needed to check the string , say for special characters ? (as a security precaution) Thank Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on select boxes and lists.
Graham, Thank you. Actually , you suggested this site to me the other day and it's great! I have read through a number of documents and have a few more to get through. How would a hacker pass an HTTP message ? That is interesting. Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > [snip] > > Hope this is not off topic, and it might be a dumb > > question, but I'm new. > > For drop down menus, list boxes, selects etc, > would > > validation be needed to check the string , say for > > special characters ? (as a security precaution) > > I have read several posts/articles on this matter > and although the actual > HTML form will only pass the values available, it is > possible for a hacker > to compose an HTTP 'message' with data other than > that provided by the HTML > form. > > So, validation is advisable. > > A site that I would highly recommend as it has > enlightened me on several > topics is: www.shiflett.org > > Graham > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on select boxes and lists.
I just remembered something (smacks myself in the head) In both my multi select and select menus I use dynamic options (meaning the options available come from a table. So: Table for states would look like this: +--+---+ | StateID | State [Label| +--+---+ | 1 |Arkansas | +--+---+ | 2 |Alabama| +--+---+ | 3 +Arizona| +--+---+ What gets stored in the database is the StateID, the column is an int. My understanding is the database just won't accept anything but an int. I mean I'm jamming on my keys now and the only thing the column will take is a real number. Based on this I think a hacker can do whatever they want by saving the page and altering the input but all it would do is fail on insertion. This make sense ? And I'm not trying to be lazy here , only practical. Of course, should I still be polite to hackers by still testing for invalid characters :) Stuart --- Graham Cossey <[EMAIL PROTECTED]> wrote: > [snip] > > > > How would a hacker pass an HTTP message ? > > That is interesting. > > read the off-list posted message from > [EMAIL PROTECTED] > > (reproduced below for the benefit of other list > members) > > Graham > -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: Simpler loop
I have rows of input fields Each row contains 3 fields. The user must fill out the entire row (all 3 fields) for things to work right. I want to generate an error in case they have only filled in 1 or 2 of the boxes. Thinking I might use something like this: foreach($skills as $key => $skill) { if ($skill != '' && $skys[$key] = '' && $slus[$key] = '') { }else if{ if ($skill = '' && $skys[$key] != '' && $slus[$key] = '') }else{ if ($skill = '' && $skys[$key] = '' && $slus[$key] != '') . above only takes into account that 1 of that 3 has been filled in. I would need another set to take into account if 2 of the 3 have been filled in. Is there a simpler way / shorter way to check conditions to do this ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Simpler loop
Yes, I think that will work, as soon as I can figure out where on the page it should go. On error should post to itself, on success it moves to next page. I put the loop on top and am getting an invalid argument for the foreach. Stuart --- "Ford, Mike" <[EMAIL PROTECTED]> wrote: > In which case: > >if ($skill!='' && $skys[$key]!='' && $slus[$key] > !='') >{ > // row is valid -- do stuff >} >else >{ > // entry has at least one value blank -- issue > error >} > > Cheers! > > Mike > > - > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information > Services, > JG125, James Graham Building, Leeds Metropolitan > University, > Headingley Campus, LEEDS, LS6 3QS, United Kingdom > Email: [EMAIL PROTECTED] > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 > 283 3211 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: Redirect - was Question: Simpler loop
I put the loop at the top of the next page, before any output to the browser: http://www.2soon2show.com/TestMulti4a.php"; ); print "You have errors"; } } ?> Before I added the redirect the print worked (and yes it doesn't belong in that part of the loop) Now the redirect is working , but the print isn't. Do I do an exit first, then the redirect and print ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Redirect then error message to user
I'm not quite sure how to get an error message to print out after a redirect. I know it's possible. Now page1 moves to page2, check below is on page2 If I leave it on page2 (without redirect), it prints error to user fine. Once it redirects no print. I also tried leaving it on form1, at the top it won't work, since the variables haven't been set yet. Not sure how to let it post form 1 to form 1 check and then on success move to form 2. { // valid - next - } else { header("Location: http://www.xx.com/page1.php"; ); print "You have errors"; exit; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirect then error message to user
Now why didn't I think of that ! Thank you Jay! Stuart --- Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] >{ > header("Location: > http://www.xx.com/page1.php"; > ); > print "You have errors"; > exit; >} > > } > [/snip] > > You either need to carry info about the error in a > session variable or > url string or something...above your redirect > happens before any error > can be sent to the browser > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirect then error message to user
This isn't working: Page2 (after page1 has been posted): else { $_SESSION['er'] = 'Please make sure to fill in all 3 corresponding values .'; header("Location: http://www.x.com/TestMulti4a.php"; ); exit; } } Page1: Opening after session_start $_SESSION['er'] = $_POST['er']; Then below in form area: print $er; (tried also echo) Am I do something wrong ? Stuart --- Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] >{ > header("Location: > http://www.xx.com/page1.php"; > ); > print "You have errors"; > exit; >} > > } > [/snip] > > You either need to carry info about the error in a > session variable or > url string or something...above your redirect > happens before any error > can be sent to the browser > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirect then error message to user
Sorry, all fixed now! Thank you for the help! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect then error message to user
See below: --- Jason Wong <[EMAIL PROTECTED]> wrote: > What are you trying to do here? > Is 'Page1' == TestMulti4a.php? > Are you trying to display $_SESSION['er'] as set in > Page2? > If so why are you assigning $_POST['er'] to > $_SESSION['er']? All you need to > do is echo $_SESSION['er']. > Yes Page1 - TestMulti4a So slightly changed and I thought it was working, seems TestMulti4a (page1) displays the error when I go to it directly (before input) So on Page2 I have: else { $_SESSION['oops'] = "Use all 3 fields to set a skill"; header("Location: http://www.lurkingforwork.com/TestMulti4a.php"; ); exit; } Page1: I even logged out of the session, thinking I was now carrying it through the session. Stuart > Jason Wong -> Gremlins Associates -> > www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet > Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > A witty saying proves nothing. > -- Voltaire > */ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect then error message to user
The only problem I'm having here is that if a user goes backwards, the error from the session variable will show up. I put an unset $.. underneath the echo but that seems to have no effect. Stuart --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: > See below: > --- Jason Wong <[EMAIL PROTECTED]> wrote: > > > > What are you trying to do here? > > Is 'Page1' == TestMulti4a.php? > > Are you trying to display $_SESSION['er'] as set > in > > Page2? > > If so why are you assigning $_POST['er'] to > > $_SESSION['er']? All you need to > > do is echo $_SESSION['er']. > > > > Yes Page1 - TestMulti4a > So slightly changed and I thought it was working, > seems TestMulti4a (page1) displays the error when I > go > to it directly (before input) > > So on Page2 I have: > else >{ >$_SESSION['oops'] = "Use all 3 fields to set a > skill"; > header("Location: > http://www.lurkingforwork.com/TestMulti4a.php"; ); > exit; >} > > Page1: > > > I even logged out of the session, thinking I was now > carrying it through the session. > > Stuart > > > > > > Jason Wong -> Gremlins Associates -> > > www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet > > Applications Development * > > -- > > Search the list archives before you post > > http://marc.theaimsgroup.com/?l=php-general > > -- > > /* > > A witty saying proves nothing. > > -- Voltaire > > */ > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: > http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect then error message to user
Brent - Thank you I will try that method. Can you elaborate more on below. I take it to mean you have one page/script that your pages are going to do all the checks. This form is 5 pages long. So I chose session variables just to keep it neat and "maybe", more secure. Stuart --- Brent Baisley <[EMAIL PROTECTED]> wrote: > I design all my pages so that "one" file handles > display, edit, > validation and save. Then I don't have to worry > about going back and > forth between pages, doing redirects or retaining > data through session > variables. Most important, the user doesn't lose > what they already > entered just because they missed a field. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form madness maybe OT
I've tried about everything and have analyzed every bit of code but I can't seem to resolve this issue. It might be off topic since I can't say for sure if this is a php problem. The issue - I have a multi page form. One page seems to throw a wrench in the whole process every time I make a simple modification. Initially I had this setup: There were 5 rounds of these. Now when I setup the array I only set it up to grab the skill[], sky[], and slu[] And all that works great ! And so basically cert[],cky[],clu[] were just dead elements. Now what I've done is dropped the cert,cky,clu elements and added 5 more sets of the skill, sky and slu. No difference in the sequence of elements in the form. Yet for some unknown reason it throws a curve to the process somehow and basically kills the transaction. I've checked, rechecked the session start and the authentication procedures. Like I say if I put the original one back in all is well. The array does not limit the number of elements. Very strange behaviour. I am not sure what to do. After a good amount of effort I thought to post in case someone with more experience might understand the possible issues. Thank you. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form madness maybe OT
--- Andre Dubuc <[EMAIL PROTECTED]> wrote: > Stuart, > > I'm no expert, but did you flush your browser? > > Hth, > Andre > Andre, thank you for the response. I'm not sure what you mean by flush the browser ? Here is what I've been doing. First, I have denied cookies from the site. Second, I've logged out and logged back in again. I think the sessionid would change then, as I've tested with the sessionid printing out. Last, I've actually closed out of the browser and re-opened. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form madness maybe OT
--- Andre Dubuc <[EMAIL PROTECTED]> wrote: > Stuart, > > Go to your browser settings, under 'Cache' (or > something similar) then clear > the cache. I struggled with a similar problem for > days . . . > > Andre > I did that, and didn't change the situation. Also I think the fact that using the original form will work seems to indicate it's not a caching / cookie / session problem. Very strange Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form madness maybe OT
Call off the troops. I reconstructed the form, step by step checking each step. All seems to be working. Stuart --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: > > --- Andre Dubuc <[EMAIL PROTECTED]> wrote: > > Stuart, > > > > Go to your browser settings, under 'Cache' (or > > something similar) then clear > > the cache. I struggled with a similar problem for > > days . . . > > > > Andre > > > I did that, and didn't change the situation. Also I > think the fact that using the original form will > work > seems to indicate it's not a caching / cookie / > session problem. Very strange > Stuart > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help: Database search and results
I have created a database search and results set. Things seem to work fine until I add the join statements into the results page query string. If I don't use the joins , the search works great. It returns the correct results based on the criteria input. If I add the joins in, then basically all i get regardless of my search criteria is a complete dump of every listing. NOW - I don't expect any suggestions based on my above question, but was not sure if it was okay to post the code. Both pages total about 325 lines. If it's okay to post it I will. Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SOLVED Re: [PHP] Help: Database search and results
Wow~! I'm getting good. --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: > I have created a database search and results set. > Things seem to work fine until I add the join > statements into the results page query string. > If I don't use the joins , the search works great. > It > returns the correct results based on the criteria > inp.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Database search and results
Ooops, not solved yet. --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: I have created a database search and results set. Things seem to work fine until I add the join statements into the results page query string. If I don't use the joins , the search works great. It returns the correct results based on the criteria input. If I add the joins in, then basically all i get regardless of my search criteria is a complete dump of every listing. NOW - I don't expect any suggestions based on my above question, but was not sure if it was okay to post the code. Both pages total about 325 lines. If it's okay to post it I will. Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validation and session variables
Having some odd behaviour. First , let me mention this is a multi page form using session variables. (This might be important) So I am doing a page by page validation, and have tried putting the code before session_start or after. Either way my session variables are getting lost. Now in order to do my validation on the same page, I have set form action to nothing action="" And upon sucess of happy validation added this code: if ($_SERVER["REQUEST_METHOD"] == "POST") { $url = "success.php"; Header("Location: $url"); } ?> The page progresses correctly but it seems the variables are gone. Sound like it makes sense ? Any suggestions or ideas. Thank you, Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
Yes the session variables are set with $SESSION[''}. The way it works is the variable gets set on the follwing pages: So, example on page 1: I have this user input field: On the following page (page 2): $_SESSION['f1a'] = $_POST['ListingName']; And all the pages follow the same method. Inputs on page 2 are $_SESSION[''] = $_POST['']; on page 3. I did try putting the session_start() at the top of the page. Didn't seem to make any difference. Just to show the validation code (and it's from a class): if ($_SERVER["REQUEST_METHOD"] == "POST") { $url = "Page2.php"; Header("Location: $url"); } ?> So, for every page I add validation too, I can see at the end from the printout, that the variables are gone, missing . Stuart --- Ligaya Turmelle <[EMAIL PROTECTED]> wrote: > Without seeing the code: > Try putting session_start() at the VERY beginning. > Also try having the > action go to the page itself ($PHP_SELF or putting > in the path). Is the > session variables being set using $SESSION['']? > > Respectfully, > Ligaya Turmelle > > > Stuart Felenstein wrote: > > Having some odd behaviour. > > First , let me mention this is a multi page form > using > > session variables. (This might be important) > > > > So I am doing a page by page validation, and have > > tried putting the code before session_start or > after. > > Either way my session variables are getting lost. > > > > Now in order to do my validation on the same page, > I > > have set form action to nothing action="" > > And upon sucess of happy validation added this > code: > > > > if ($_SERVER["REQUEST_METHOD"] == "POST") { > > $url = "success.php"; > > Header("Location: $url"); > > } > > ?> > > > > The page progresses correctly but it seems the > > variables are gone. > > Sound like it makes sense ? Any suggestions or > ideas. > > > > Thank you, > > Stuart > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation and session variables
See inline: --- "Ford, Mike" <[EMAIL PROTECTED]> wrote: > The only circumstance under which I can think this > might happen is if the > session id is not being propagated by cookie -- > either because they're > blocked in the browser, or because you have them > switched off in php.ini. They are not switched off in php.ini. I do have them "semi blocked" in the browser, i.e. set to "allow for session" > Even if you have session.use_trans_sid enabled, It is enabled. > PHP cannot rewrite URLs in the header() call, so you > have to include the session ID manually. > You should do this regardless of whether you expect > cookies to be enabled, so that it will work ok even > > in the unexpected situation of having cookies > turned off. > > Fortunately, the standard PHP constant SID is > provided for exactly this > purpose, so your header call above should be: > >header("Location: $url?".SID); This is all I need to include the SID ? Thank you Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
Yes I do have session_start on every page at the top. Stuart --- Marek Kilimajer <[EMAIL PROTECTED]> wrote: > Stuart Felenstein wrote: > > Yes the session variables are set with > $SESSION[''}. > > The way it works is the variable gets set on the > > follwing pages: > > > > So, example on page 1: > > I have this user input field: > > type="text" > > id="ListingName" maxlength="20" /> > > > > On the following page (page 2): > > $_SESSION['f1a'] = $_POST['ListingName']; > > > > And all the pages follow the same method. Inputs > on > > page 2 are $_SESSION[''] = $_POST['']; on page 3. > > > > I did try putting the session_start() at the top > of > > the page. Didn't seem to make any difference. > > You MUST have session_start() at the beginning of > every page that uses > session, and if you allow session id to be included > in urls you MUST > have session_start() in every page. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation and session variables
Okay, I altered the code. Same thing, session variables gone. I then deleted the "session only" cookie. Also took the rule out in the browser , so browser is accepting all cookies from site. Still no change. Not to be redundant but here is the code again:(I xxx'ed out some fields in the restrict access line so they are not public) Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
--- Chris Shiflett <[EMAIL PROTECTED]> wrote: > So, the first thing to try is using a proper > Location header: > > header('Location: http://example.org/success.php'); > > Hope that helps. > > Chris > Thank Chris , but met with same behaviour. 2 Questions: 1- Should I drop the $url line ? I tried both ways , no change though. 2- Do I still need to call the SID ? http://www.mysite.com/nextpage.php); } ?> Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
Okay, first, sorry, but what is top post? Writing before the reply or after ? Second, I'm not entirely sure where the session_write_close() belongs, because here below, isn't this a redirect? back to page2 if there are validation errors: if ($WAFV_Errors != "") { PostResult($WAFV_Redirect,$WAFV_Errors,"page2"); or is it solely in: session_write_close() if ($_SERVER["REQUEST_METHOD"] == "POST") { $url = "TestMulti3.php"; Header ('Location: http://www.mysite.com/page3.php); Thank you , Stuart --- Jason Wong <[EMAIL PROTECTED]> wrote: > On Wednesday 27 October 2004 11:31, Stuart > Felenstein wrote: > > Please do not top post. > > > Yes I do have session_start on every page at the > top. > > As I have pointed out in a previous thread and Mike > has pointed out in this > thread you MUST use > > session_write_close() > > before you do a redirect. > > -- > Jason Wong -> Gremlins Associates -> > www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet > Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > Please come home with me ... I have Tylenol!! > */ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
--- Chris Shiflett <[EMAIL PROTECTED]> wrote: > On each page, it might be good to add some debugging > information near the > top (where session_start() is): > > session_start(); > echo '' . htmlentities(print_r($_COOKIE, true)) > . ''; > echo '' . htmlentities(print_r($_GET, true)) . > ''; > echo session_id(); > ... > I added this in , on top, right under session_start() as shown and get this error: Warning: Cannot modify header information - headers already sent by (output started at /home/lurkkcom/public_html/page1.php:6) in /home/lurkkcom/public_html/page1.php on line 54 So it's clashing with the redirect: Header ('Location: http://www.mysite.com/page2.php?'.SID); Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validation and session variables
--- Chris Shiflett <[EMAIL PROTECTED]> wrote: > This is most likely due to your malformed Location > header. It requires an > absolute URL, and some browsers (notably several > versions of IE, but there > may be others) do not send the proper Cookie header > when requesting the > new URL if you use a relative one. > > So, the first thing to try is using a proper > Location header: > > header('Location: http://example.org/success.php'); > I'm ready for the fork in the eye now ! ;) Moved session_start() to way on top. Placed the following in the redirect area: http://www.mysite.com/page2.php?'.SID); } ?> Following Jason's last post, based on my server using 4.3.8 I did not include the session_write_close() This is defintely a tough one! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SOLVED - Validation and session variables
I guess this was the one thing I overlooked. Since the page had to return to itself if validation errors, it was already set in the validation script to do so. So, as I had shown in my original post the form action was blank ..well "" Simple solution to keeping my session vars, set action to page itself. i.e. Page1 , form action = "page1.php" then the redirect like you all help me with. Sweet and working ! I might be back when i get to page 5 :) Thanks to all! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validation and session variables
I guess my resolution was a fluke. Recap: Adding validation kills my session variables Now I tested a few things, SID is consistent across pages, so a new sid and cookie are not being generated. Perhaps it's a bug, Im on PHP 4.3.8 Here is the code again, perhaps something will jump out. http://www.xx.com/page2.php?'.SID); } ?> I just set an echo on page2 and page3 of the first session variable 'listingname'. If I have the validation code in page1 , it doesn't even make it to page2 I'm really sorry for posting this again. Maybe it's a bug or I'm posting my variables wrong or Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation and session variables
--- Graham Cossey <[EMAIL PROTECTED]> wrote: > I think we need to know what happens when this > function returns the user to > the script upon finding an error. Are all the form > field values passed back? Doesn't seem that they are. I tripped an error on page1 , had an echo set for the first session variable. The page popped back with my errors, but no session variable. But! maybe that is tied into what I said towards the end of my last thread. All page1 has is: The session variable isn't posted until page2: $_SESSION['f1a'] = $_POST['ListingName']; > Does it do anything at all with the session? Does it > pass the SID? It's passing the SID yes. SID number remains consistent. I am not checking the /tmp file though. I'll assume at this point it's at 0kb > > Are you saying that page1 always fails validation > even if you enter all the > form fields correctly? No not at all. Validaton works fine. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validation and session variables
--- Graham Cossey <[EMAIL PROTECTED]> wrote: > I think we need to know what happens when this > function returns the user to > the script upon finding an error. Are all the form > field values passed back? > Does it do anything at all with the session? Does it > pass the SID? > I want to append my previous message. Page 1 is not showing a SID. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code help on a multi select list
I want to do a server side trap if a user selects more from a mult select list then allowed. Just unsure and didn't find any examples. Seems people rely more on javascript these days. So here is how I grab the array: if ( is_array( $_REQUEST['LurkerIndustry'] ) ) { $_SESSION['l_industry'] = array_unique( array_merge( $_SESSION['l_industry'], $_REQUEST['LurkerIndustry'] ) ); } here is my somewhat hazy notion: if ( is_array( $_REQUEST['LurkerIndustry'] ) ) { $_SESSION['l_industry'] = array_unique( if $l_industry > 5 ( Here I'm guess I need to redirect back to page with and error message) else array_merge( $_SESSION['l_industry'], $_REQUEST['LurkerIndustry'] ) ); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code help on a multi select list
--- Reinhart Viane <[EMAIL PROTECTED]> wrote: > I would choose javascript to to check this > This response I don't understand. There are 50 options and the intent is to allow 3 of those 50. Then some "genius" comes along and turns off javascripting and chooses all 50. I KNOW it will happen. I wouldn't even dare to dream that it may not. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code help on a multi select list
--- Jay Blanchard <[EMAIL PROTECTED]> wrote: > What is not to understand here...you are the one who > said, "I want to do > a server side trap". JavaScript would be the only > way to do that. Sorry, I used the wrong terminology. I think my statement was interpreted as using javascript at the server level. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code help on a multi select list
--- Greg Donald <[EMAIL PROTECTED]> wrote: > Bah.. Mountain Dew and a couple of Sudafed is where > it's at. :) > > That just doesn't sound right. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session and validation
I had this thread going yesterday. Then basically think it reached a stalemate. I'm wondering has anyone setup forms using session variables and validation. Validation where the validating is done on the same page, and the redirected on success ? Maybe that is my problem , that session variables will get blown away when the validations are run in the same page. Shouldn't be right ? Let me ask though if I setup just a validation page, then on success I'm still doing a redirect (cause it's a multi page form) Or if I validate on the next page and there is an error, I redirect back, but then I also have to consider how the error is going to get printed on the first page. Anyone ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session and validation
--- Chris Shiflett <[EMAIL PROTECTED]> wrote: > --- Stuart Felenstein <[EMAIL PROTECTED]> wrote: > > I had this thread going yesterday. Then basically > > think it reached a stalemate. > > I think you need to try to simplify your code to the > most basic example > that demonstrates the problem. By doing this, you'll > achieve one of two > things: > > 1. Figure out the problem yourself. > 2. Generate a perfect example that we can use to > better understand your > problem and suggest a solution. > Yes, this is exactly what I did and why I dredged up this topic again: Here is the example: testarray (page1) //Start the session 5) { echo "you have selected too many industries"; exit; } ?> http://www...com/TAresults.php";); } ?>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> Untitled Document >Accounting >Entertainment >label >Advertising >Customer Service >Informatin Technology TAresults (page2): http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> Untitled Document "; echo $industry['0'].""; echo $industry['1'].""; echo $industry['2'].""; echo $industry['3'].""; echo $industry['4'].""; echo $industry['5'].""; echo $industry['6'].""; echo $industry['7'].""; echo $industry['8'].""; echo $industry['9'].""; echo $industry['10'].""; echo $industry['11'].""; ?> The results here, are whether the check passes or not the variables never echo. If I set action on page 1 to TAresults.php , then they echo out fine. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session and validation
--- Graham Cossey <[EMAIL PROTECTED]> wrote: > So, if this is the result of a form submission how > are you getting the POST > variables? > How/where is $industry being set? I appears that you > are assuming that > variables are 'maintained' within a script, they are > not. You have to > remember that although you are running the same > script it is not the same > 'instance' of the script as a request/response has > occurred. You MUST pass > and retrieve SESSION/POST/GET variables if you > intend to use them in your > script. > Yes, I see your point about the instance changing. I made the change and set session = post prior to the redirect and it's working proper. Now, I will need to go back and try my other scripts to see if this holds up in them. I thought I already tried , but a fresh start may help. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] VOTE TODAY
--- Angelo Zanetti <[EMAIL PROTECTED]> wrote: [snip] session_start(); $_SESSION['foo']= "screw all this political bullsh1t! who cares about the americans, they are just after oil and I dont care as long as bush doesnt win. long live iraq!!!"; unset($foo); session_destroy(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Lost session variables still confounding me
I think I've tried just about everything that I found googling. Still no luck. I'm throwing this out again, with the chance that something missed before maybe noticed. Page 1: //Start the Session - begin Block @session_start(); Page 2: //Start the Session - begin Block @session_start(); //Set the session variable, input on Page 1 $_SESSION['f1a'] = $_POST['ListingName']; Page 3: //ON this page, I check that f1a still exist using an echo - generally it does unless : //Start the Session - begin Block @session_start(); if (count($myarray) > 5) { $_SESSION['arrayerr'] = "you have selected too many industries"; header ("Location: Page2.php"); exit; } If the validation above passes, no problem. But if it doesn't, once it redirects, the session variable , f1a is bye bye. I've tried passing the session_id, session_name, i've printed out both to make sure they remain the same. I' ve done relative and absolute paths. Searching for this problem , it seems I'm not the only one who has suffered with this issue. Some was prior php 4.3 when session_write_close was needed. I've thrown that in as well. I just don't get it. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lost session variables still confounding me
--- Richard Davey <[EMAIL PROTECTED]> wrote: > Unless I'm mistaken - you are redirecting back to > Page 2 upon an > error, right? Well according to the code posted, the > second you hit > Page 2 again, you are over-writing whatever is in > the f1a session > variable with the contents of the $_POST var, which > naturally will not > exist, hence you'll blank it out every single time. > Your not mistaken. That is what's happening. I just don't know how to fix it . Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Lost session variables still confounding me
--- Richard Davey <[EMAIL PROTECTED]> wrote: > Before setting the session value in Page 2, check > for the existence of > the $_POST value first. > > if (isset($_POST['var'])) > { >$_SESSION['var'] = $_POST['var']; > } > > When you now redirect to Page 2 upon an error, it'll > skip this block > because the $_POST var won't exist. > I'm a bit confused, this fixes the problem ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Lost session variables still confounding me
--- Reinhart Viane <[EMAIL PROTECTED]> wrote: > Suppose Richard means: > > If (isset($_POST['ListingName'])) { > $_SESSION['f1a'] = $_POST['ListingName']; > } Right, I've tried all three variations , none of which, I'm sorry to report, have helped. The variable is alive with any of the code including the one I had originally. It seems to do a reset though when it's redirected. I've even tried: Page3: if (count($LurkerIndustry) > 5) { $_SESSION['arrayerr'] = "you have selected too many industries"; $_SESSION['f1a'] = $_POST['ListingName']; header ("Location: TestMulti2.php"); exit; } Thinking that by sending the variable back to page 2 it would hold. The error variable takes. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Lost session variables still confounding me
--- Reinhart Viane <[EMAIL PROTECTED]> wrote: > So, if I understand correct, even with the isset > code on the second page > $_SESSION['f1a'] is set to empty? > That's strange. > Still I wonder why you are inputting the error > messages and the redirect > in a session variable. > Yes, the isset is not working. It probably isn't necessary anyone since I've got a validate / required field set. I'm not sending the redirect in a session variable. Only the error message. That is the way I know how to do it. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Lost session variables still confounding me
--- "Ford, Mike" <[EMAIL PROTECTED]> wrote: > > Page3: > > > > if (count($LurkerIndustry) > 5) { > > $_SESSION['arrayerr'] = "you have selected too > many industries"; > > $_SESSION['f1a'] = $_POST['ListingName']; > > header ("Location: TestMulti2.php"); > > exit; > > } > > Well, that's even worse -- because page3 can *never* > be reached as the > result of submitting a form, its $_POST[] will > *always* be empty -- so this > assignment is also bound to set $_SESSION['f1a'] to > NULL. > Mike, I'll heed your advice, since you haven't let me down before :). But the variable lasts , I echo it on every page, including page6 where it's transacted into the database. I'm not sure why you say that Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[4]: [PHP] Lost session variables still confounding me
--- Richard Davey <[EMAIL PROTECTED]> wrote: > Try sticking this on Page 2 (ensure you have a > session_start() at the > top of the page and that you replace the 'var' text > below with the > correct ones. > > if (isset($_POST['var'])) > { >echo 'POST value found, setting the session var > now'; >$_SESSION['var'] = $_POST['var']; > } > else > { > echo 'No POST value found, dumping session > contents'; > print_r($_SESSION); > } > > Run it - make it error - what does it end up saying? > Before the redirect: POST value found, setting the session var now After the redirect: No POST value found, dumping session contentsArray ( [xx_user_xxx] => username [xx_id_xxx] => 47 [xx_level_xxx] => BasicUser [f1a] => [WAVT_TestMulti2] => [f1b] => [f1c] => [f1d] => [f1e] => [f1g] => [inder] => you have selected too many industries ) Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Lost session variables still confounding me
--- "Ford, Mike" <[EMAIL PROTECTED]> wrote: > Page 3: > >if (count($myarray) > 5): > $_SESSION['arrayerr'] = "you have selected too > many industries"; > session_write_close(); > header ("Location: Page2.php?".SID); > exit; >endif; > > Hope this helps. Mike, once again you've come through. This worked! But , let me ask, can it have anything to do with the endif ? I asked becasue I tried the session_write_close and the SID before with no success. Now that it's working , the only thing different is the endif; . Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Lost session variables still confounding me
--- Jason Wong <[EMAIL PROTECTED]> wrote: > Maybe what you had before was: > > if (count($myarray) > 5) >$_SESSION['arrayerr'] = "you have selected > too many industries"; >session_write_close(); >header ("Location: Page2.php?".SID); >exit; > > And yes that has a totally different behaviour to > the code with the "endif;" > construct. > Yep, that is what I had. So, no parse error, but did not work right either. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: Validation on a text field
I have a field that is an actual Mysql Text column, aka like a blob. I'm wondering if doing a standard validation that checks for characters outside of the alphanumeric range is enough. I'm imagining some users will cut and paste from a Word or PDF doc into the field. I've done it myself and no weird characters are showing up. Any thoughts ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on a text field
It's a mysql text field. Stuart --- Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] > Any thoughts ? > [/snip] > > I thought I'd have lunch today, but I didn't. > > Is it a 'text' data type, or 'BLOB', (you said, > "actual Mysql Text > column, aka like a blob") because the distinction is > needed. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on a text field
--- "Vail, Warren" <[EMAIL PROTECTED]> wrote: > I also don't know if MySQL will police things input > to a text column to make > sure they are valid ascii text characters. > No Mysql won't do it. PHP validation would have to be involved. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on a text field
May I ask why you are suggesting this function ? Stuart --- Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] > It's a mysql text field. > [/snip] > > You can use htmlentities() on the information placed > into the field > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question: Validation on a text field
--- Jay Blanchard <[EMAIL PROTECTED]> wrote: > [snip] > May I ask why you are suggesting this function ? > > > You can use htmlentities() on the information > placed > [/snip] > > Because it will convert things like quotes into > their HTML counterparts > before you place them into the table. I'm still a bit fuzzy on how to write it out. So if field is labelled f5 Then I'm doing a $_SESSION['f5'] = $_POST['MyText']; then I think it would be $f5 = htmlentities($f5, ENT_QUOTES); insert $f5 into database ? Thanks Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: Validation on a text field
--- Ben Ramsey <[EMAIL PROTECTED]> wrote: > You should also use mysql_real_escape_string() on > the data from the client. Even though Magic Quotes GPC is turned on ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Initializing variables
I'm reading PHP security paper by Chris Shiflett. Trying to figure out what is meant by first initializing a variable. Now, just for the record, I'm not completely dumb. I know you can start with a $var = 2 What I want to know is if the variable assignment is unknown, as in a user form. Would I then just initialize the variables to 0 ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Questions about mysql_real_escape_string and addslashes
First I'm a bit unsure , because in the manual it states that you must use mysql_real_escape_string on binary data. So first question, what constitutues binary data, a file or just an integer? Second question - Since magic_quote_gpc is enabled on my server (and I have no choice) - I gather I must use addslashes() 3rd- Some of the user input translates to an int value where I later do a join for the actual label. I believe those fields are protected naturally since the database won't accept anything but an int. 4th - With both of these functions it looks like they become part of the sql query. I could use some help in understanding how to set up variables using both functions. In otherwords, an example of how they get coded. Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Questions about mysql_real_escape_string and addslashes
--- "M. Sokolewicz" <[EMAIL PROTECTED]> wrote: (http://www.php.net/manual/en/function.mysql-real-escape-string.php) I have my eye on example 3: The Quote_Smart function. Do I have to list all the variables out though or is there a way to have it check everything passing through ? What would nice is if I didn't have to put the Quote_smart function in every query statement but have it test everything? Stuart > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: Passing error messages
I've started getting into the habit of passing error messages through session variables, particularly on redirects. >From some peoples reaction on this list I gather it's not the best practice. What is an alternative way ? I believe it's through a URL. not sure how to go about that method Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question: Passing error messages
--- Daniel Schierbeck <[EMAIL PROTECTED]> wrote: > I'm not quite getting what you're saying - are you > sending the error > messages on to a new page?! The usual and simple way > of doing this is > the good 'ol OR operator: > I'm saying, currently if there is an error and the script needs to exit, I'm doing this : if ..error { $_SESSION['ErMsg'] = "Submit Failure"; header (location: ) exit; } I want to know what alternatives there are to error messages aside from using a session variable. Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question: Passing error messages
--- Daniel Schierbeck <[EMAIL PROTECTED]> wrote: > Where are you redirecting the client to? An error > page? Either an error page or back out to a main page. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nested foreach ?
I have 3 arrays. 3 for 3 fields in a table (all part of 1 record) array1 - field1 array2 - field2 array3 - field3 What I've been doing which works good with one array: if ( is_array( $_SESSION['foo'] ) ) { foreach ( $_SESSION['foo'] as $x ) { sql .= "INSERT INTO TABLE (... VALUES ($x) Just can't seem to figure out how with three arrays. help appreciated. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help:escape_string and stripslashes
I asked a question yesterday about this but I think my question is now more fine tuned: Right now I have about 50+ session variables that will be inserted into my mysql database in a transaction. I need to do the mysql_real_escape_string and because magic_quotes_gpc is turned on stripslashes as well. I'm wondering if there is a way to use a function or class within my connection script to take care of all of this ? As oppposed to listing everyone out ? I know I can pass all the variables as an array but some of the variabls are arrays themselves, so not sure how that would work. Any suggestions ? Thank you Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help:escape_string and stripslashes
--- Jordi Canals <[EMAIL PROTECTED]> wrote: > In the manual > http://es2.php.net/manual/en/function.get-magic-quotes-gpc.php > you have an example just for that. Take a look to > the Example 2. > Ok, that makes sense. Thank you . Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help:escape_string and stripslashes
--- Stuart Felenstein <[EMAIL PROTECTED]> wrote: On second thought, I have a question. What is the $value in the example ? Does that mean I put in my own values ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help:escape_string and stripslashes
--- Jason Wong <[EMAIL PROTECTED]> wrote: > 2) Lookup array_map() and understand what it does. > > 3) stripslashes_deep() is a recursive function (ie. > it calls itself). You > should find a good tutorial on recursive functions > to learn exactly what it > does. Thank you Jason. Another thing I'm wondering and not clear on . I have 5 pages of forms, a 6th page is where the processing , transaction is taking place. Would it be sufficient to add stripslashes_deep() to only the last page (6th page) ? Each succeeding page, posts the previous page varibles. I'm guessing the last (6th page) would be enough, but would like to confirm. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: array_walk
This array_walk() looks like a good function Would this be a legitimate call: array_walk($myarray, 'mysql_real_escape_string'); ? Thank you, Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array_Walk error messages
Can anyone give me a clue what I have done wrong here. //These would be passed as ints: array_walk($l_industry, 'mysql_escape_string'); Warning: Wrong parameter count for mysql_escape_string() in /xxx//public_html/Test2.php on line 104 //These would be passed as ints: array_walk($l_tterm, 'mysql_escape_string'); Warning: Wrong parameter count for mysql_escape_string() in /xxx//public_html/Test2.php on line 105 //These are strings array_walk($skills, 'mysql_escape_string'); Warning: Wrong parameter count for mysql_escape_string() in /xxx/x/public_html/Test2.php on line 106 //These are ints: array_walk($skys, 'mysql_real_escape_string'); Warning: mysql_real_escape_string() expects parameter 2 to be resource, integer given in /xxx/x/public_html/Test2.php on line 107 //These are ints: array_walk($slus, 'mysql_escape_string'); Warning: Wrong parameter count for mysql_escape_string() in /xxx//public_html/Test2.php on line 108 Thanks Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question: Exiting a script
Say I have a script that processes input data. How do I get the script to work, where after processing the user is taken to another page ? The script outputs nothing to the screen and will end either in failure or success. Seems header won't work for me. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: Exiting a script
--- Richard Davey <[EMAIL PROTECTED]> wrote: some > text or >white-space, aborting'; > } > else > { > Richard Davey I think white space is my problem. What causes white space ? Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question: Exiting a script
Never mind , I found it! http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd"> One of these days I'll master the header function ;) Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable for search results
I have a form element which allows a user to go back "x number of days" in the records. $sql.=sprintf("SELECT * FROM records WHERE Date_Sub(Curdate(), interval day) "$%s" <= PostStart") This formula works when I actually hardcode the number of days in where this mess --> "$%s" is right now. I'm not entirely sure how this should be coded. Can I put the variable right there? I'll take any suggestions, cause I'm stuck here. Thank you, Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Variable for search results
--- Ben Ramsey <[EMAIL PROTECTED]> wrote: > I'm not exactly sure what the SQL statement you have > above is supposed > to do, but you could just do something like this: > > $curdate = date('Y-m-d H:i:s'); > $sql = "SELECT * FROM records WHERE '$curdate' <= > PostStart;"; > I'm having some problems still. I'm trying to work here with a Dreamweaver extension and the code is not clear. Are there are good tutorials around , to learn how to create a database search and results page. Basically there would be about 6 form elements, some list boxes, some text fields. The more criteria that is filled in on the form the more refined the search. Not sure if this is beyond my skill level or not. Beginner. Thank you Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help: Database Search
I am creating a database search form and results. Running into a problem though. I have two form elements, both that are fed by tables that have int values (1, 2 , etc) my sql statement is such: SELECT vendorjobs.PostStart, vendorjobs.JobTitle, vendorjobs.Industry, vendorjobs.VendorID, vendorjobs.LocationCity, vendorjobs.TaxTerm FROM vendorjobs WHERE vendorjobs.Industry = '$Ind' AND Date_Sub(Curdate(), interval '$Days' day) <= PostStart " But if the user decides to only use one of the elements, then I don't want the query to return nothing because of the "And" in the where clause so I have these 2 statements that set a default value (shown here as 0 in the event one of the two elements aren't selected: (Having no luck as the form still only works correctly if I've set both elements) $Ind = "0"; if (isset($_POST['Ind'])) { $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] : addslashes($_POST['Ind']); } $Days = "0"; if (isset($_POST['Days'])) { $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] : addslashes($_POST['Days']); Thank you , Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Database Search
--- Jon Hill <[EMAIL PROTECTED]> wrote: > You might want to try looking up the syntax for left > join queries. > I think this might be what you are after. > > http://dev.mysql.com/doc/mysql/en/JOIN.html > It has nothing to do with left joins. It works fine provided I do one of two things, make selections on both form elements, or change the where statement to "or" instead of and. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Database Search
--- Jason Wong <[EMAIL PROTECTED]> wrote: > Why not build your sql query according to whether or > not whatever you want is > selected or not. That way debugging is easier as > you won't be looking at > queries that contain redundant "... AND 0 ...". > Jason, How would I do that ? Care to share a short exmaple ? Thank you Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looking for pointers to mysql functions
I'm building a search function and I think most of the search part is solid. Now I'm trying to figure out the results part. Since my results would return about 7 fields per record, I'm thinking mysql_fetch_row over mysql results works better ? But I don't want every field from the row returned, only specific ones. Also, I want to allow for all records that meet criteria to be returned, and will set up a user variable, so they can choose how many records per page come back. Can anyone share some ideas or pointers to documentation that will allow me to set this up ? Very much appreciated! Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php