Page 1 of 1

problem fetching info from form with name + id

Posted: Tue Apr 18, 2006 8:17 pm
by tomer_shim
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,
I am using snoopy php class ([url]http://sourceforge.net/projects/snoopy[/url]) 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: Select all

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";
while im trying to use this code for a regular form which has Text input boxes look like:

Code: Select all

<input type="text" name="title" size="50" maxlength="50">
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: Select all

<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);">
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!!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Apr 19, 2006 5:44 am
by MentalWealth
not sure on snoopy class etc and its use/syntax...........but shouldnt this:

Code: Select all

$submit_vars['name[id]']
be:

Code: Select all

$submit_vars[$name[id]]
how would the first one work? your assigning a string : "name[id]" the value would be stated like the second one.


M

Posted: Wed Apr 19, 2006 6:57 am
by tomer_shim
guess so, but it didnt help, i just tried to change that. :( any other ideas please?

Posted: Wed Apr 19, 2006 9:16 am
by feyd
The submission data should be available through $_POST.

Try using print_r(), var_dump() or var_export() on it to see how the data is submitted.