tomer_shim Posted April 19, 2006 Share Posted April 19, 2006 Hello,I am using snoopy php class ([a href=\"http://sourceforge.net/projects/snoopy\" target=\"_blank\"]http://sourceforge.net/projects/snoopy[/a]) to build a 'auto submitter' for an online form. to do so, I used an example code from the README page included in that class docs.this is the example:[code]include "Snoopy.class.php"; $snoopy = new Snoopy; $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html"; $submit_vars["q"] = "amiga"; $submit_vars["submit"] = "Search!"; $submit_vars["searchhost"] = "Altavista"; if($snoopy->submit($submit_url,$submit_vars)) { while(list($key,$val) = each($snoopy->headers)) echo $key.": ".$val."<br>\n"; echo "<p>\n"; echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n"; } else echo "error fetching document: ".$snoopy->error."\n";[/code]while im trying to use this code for a regular form which has Text input boxes look like:[code]<input type="text" name="title" size="50" maxlength="50">[/code]Then it works, all i need to do is edit the $submit_url and the $submit_vars array to the input 'name's.The problem starts when i tried to use that class for input boxes which includes array's like:[code]<input type="text" name="title[]" size="50" maxlength="50" id="dt9" onchange="donh(this.id);"><input type="text" name="url[]" size="30" id="du9" onchange="donh(this.id);">[/code]I problem is that i dont know how to write the name of each of these input boxes in the $submit_vars array. i tried stuff like $submit_vars['name[id]'] = "something" (for example $submit_vars['title[dt9]'] = "blabla") but it didnt work. I need to know what is the syntax to do so.This will really halp my project if someone could please help me.Thank you in advance!! Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 19, 2006 Share Posted April 19, 2006 Got no idear but trying good luck mate.[code]$url=$submit_vars["submit_url"];[/code] Quote Link to comment Share on other sites More sharing options...
tomer_shim Posted April 19, 2006 Author Share Posted April 19, 2006 that aint really going to fix my issue :( , but thank you for trying.anyone have other ideas? Quote Link to comment Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 Simply do the same thing as before.$submit_vars['name'] = 'Whatever';Or to access a specific key:$submit_vars['name'][1] = 'Whatever'; Quote Link to comment Share on other sites More sharing options...
tomer_shim Posted April 19, 2006 Author Share Posted April 19, 2006 what the name stands for though? the input line contains Name and ID, which one goes under 'name' on the $submit_vars array?i mean, accoring to:<input type="text" name="title[]" size="50" maxlength="50" id="dt9" onchange="donh(this.id);">how the line should look like?$submit_vars['title'] = 'Whatever';$submit_vars[dt9'] = 'Whatever';which one should i use? in one i put the title (name in input) , in the other i put the id (id in input).if u use title, its actually then name of the hole array cause i have lots of input boxes like that, here only ID changes. and if i put only ID i miss the Title name.what sould i do?thanks in advance. Quote Link to comment Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<input type="text" name="title[]" size="50" maxlength="50" id="dt9" onchange="donh(this.id);">how the line should look like?$submit_vars['title'] = 'Whatever';$submit_vars[dt9'] = 'Whatever';[/quote]The "id" attribute is irrelevant, since it's not sent.It depends, whenever you have fields named whatever[], PHP will get an array named whatever. For example:[code]<input type="text" name="fruit[]"><br /> <<-- If you write 'banana here',<input type="text" name="fruit[]"><br /> <<-- 'apple' here<input type="text" name="fruit[]"><br /> <<-- and leave this blank[/code]You will get an array:[code]Array( [0] => banana [1] => apple [2] => )[/code]So, to access it, you must use $_POST['field_name_here']['position_here']. To get "banana", I would use $_POST['fruits'][0]. Quote Link to comment Share on other sites More sharing options...
tomer_shim Posted April 19, 2006 Author Share Posted April 19, 2006 thank you, but you have any idea how can i send the info?with snoopy class im trying to simulate form submit, so i actually need to [i]send[/i] the information with $submit_vars to the php page which include the form, and not [i]get[/i] the data with $_POST.any idea how can i send it with $submit_vars which used in snoopy class?Thank you for trying to help, in advance! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.