Need help with query string

brentb

(__TNT__)~
Jun 13, 2011
281
4
0
Hey,

I would really appreciate any help I could get with this. Its been a huge headache for me all day. I normally don't create code but im pretty good at editing other peoples stuff and combining php together and stuff like that. This is out of my league... I need a sample query string that will post the information when put in the URL in replacement of the webform. Don't ask why, I just need this. We are losing a ton of sign ups because of this so it is VITAL I get this corrected asap. Here is the webform code...

<form accept-charset="UTF-8" action="https://PRIVATE CODE.infusionsoft.com/app/form/process/43b141428387198ba51d1a12abeeb800" method="POST" name="Standard CoReg Mail Form" style="height:100%; margin:0" target="">
<input name="inf_form_xid" type="hidden" value="43b141428387198ba51d1a12abeeb800" /><input name="inf_form_name" type="hidden" value="Standard CoReg Mail Form" /><input name="infusionsoft_version" type="hidden" value="1.22.11.28" />
<div class="blue beta-base beta-font-b" id="mainContent" style="height:100%">
<table cellpadding="10" cellspacing="0" class="background" height="100%" width="100%">
<tbody>
<tr>
<td align="center" valign="top">
<table bgcolor="#FFFFFF" cellpadding="20" cellspacing="0" class="bodyContainer" width="100%">
<tbody>
<tr>
<td bgcolor="#FFFFFF" class="body" sectionid="body" valign="top">
<div class="text" id="webformErrors" name="errorContent">
</div>
<div>
<div class="authoring-image image-snippet" contentid="image">
<div class="imageSnippet-alignDiv" style="TEXT-ALIGN: center">
<img align="bottom" alt="ibid2SAVE" border="0" height="57" manualresize="false" src="https://cff87798.infusionsoft.com/Download?Id=466" title="ibid2SAVE" width="320" />
</div>
</div>
</div>
<div>
<div style="height:20px">
<div style="border-bottom:1px solid #CCCCCC; height:10px">
 
</div>
<div style="height:10px">
 
</div>
</div>
</div>
<div>
<table class="infusion-field-container" style="width:100%">
<tbody>
<tr>
<td class="infusion-field-label-container">
<label for="inf_field_FirstName">First Name *</label>
</td>
<td class="infusion-field-input-container" style="width:200px">
<input class="infusion-field-input" id="inf_field_FirstName" name="inf_field_FirstName" type="text" />
</td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="infusion-field-container" style="width:100%">
<tbody>
<tr>
<td class="infusion-field-label-container">
<label for="inf_field_LastName">Last Name *</label>
</td>
<td class="infusion-field-input-container" style="width:200px">
<input class="infusion-field-input" id="inf_field_LastName" name="inf_field_LastName" type="text" />
</td>
</tr>
</tbody>
</table>
</div>
<div>
<table class="infusion-field-container" style="width:100%">
<tbody>
<tr>
<td class="infusion-field-label-container">
<label for="inf_field_Email">Email *</label>
</td>
<td class="infusion-field-input-container" style="width:200px">
<input class="infusion-field-input" id="inf_field_Email" name="inf_field_Email" type="text" />
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div style="height:25px; line-height:25px">
 
</div>
</div>
<div>
<table class="infusion-field-container" style="width:100%">
<tbody>
<tr>
<td class="infusion-field-input-container" style="width:200px">
<table class="infusion-checkbox-radio-table">
<tbody>
<tr>
<td class="infusion-checkbox-radio-input-container" valign="top">
<input id="inf_option_Signmeupfortheibid2SAVEmailinglist" name="inf_option_Signmeupfortheibid2SAVEmailinglist" type="checkbox" value="410" />
</td>
<td class="infusion-checkbox-radio-label-container" valign="middle">
<label for="inf_option_Signmeupfortheibid2SAVEmailinglist">Sign me up for the ibid2SAVE mailing list  </label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div style="height:15px; line-height:15px">
 
</div>
</div>
<div>
<div class="infusion-submit-button" style="text-align:center">
<input style="height:30px; width:300px" type="submit" value="Submit" />

Here is a sample of what im looking for:

http://servernamehere.list-manage1.com/subscribe/post?u=a661a01509621af9dd4ae1934&id=fcd36a9c39?source=websitenamehere.com&fname=john&lname=smith&email=fakeemail@yahoo.com&ip=123.24.15.1®date=00/00/00&username=testname&group=1

If someone can give me the correct query string I don't have much to offer but will tweet your website out to 5000+ of my followers on Twitter.
 



Well, when you fill out a web form and click submit... it doesn't just magically get there. It goes into a URL form which the server can read and knows what to do with it and where the information goes in the database. So I need to know what my form sends as this URL. I don't care if it has silly name like Johnathantitis Peabodyman in the query string as it would need to have something listed in there under first and last name.

Once you get this query string you could put in whatever info you want (instead of Johnathantitis Peabodyman), put it in your URL bar and press enter and it would add it to my database and my newsletter would automatically get sent out.

Hope that helps sort out any confusion.
 
When it's in the URL, it is a HTTP GET and not a POST.

The code you posted though uses POST (form method="POST").

What you want to do is look at all the fields in the form, whether they are radio buttons, input or textareas and find the 'name' attribute. From these, you can build a set of key-value pairs (name, value).
they would be in the form:
name=value&
name2=value2&
name3=value3&

without the line breaks. In a POST, the query string would go in the content section (after the headers and a newline) in your HTTP request, in a GET, it would go in the URL immediately after the script location and a ?. This is the only real difference between HTTP GET and POST.

example:
http ://domain.com/scripts/proc_get.cgi?name=value&name2=value2&name3=value3

In PHP, you can build a query string from an associative array with http_build_query() , this is useful for GET requests. For POSTs, you can do it with curl



You can't tell from the code provided where it goes in the database because that info is in the script that processes the form.
 
Well I have made some progress... This is what I have got:

https: //MYPRIVATECODEHERE.infusionsoft.com/app/form/43b141428387198ba51d1a12abeeb800post?inf_form_xid=43b141428387198ba51d1a12abeeb800&inf_form_name=Standard CoReg Mail Form&infusionsoft_version=1.22.11.28&inf_field_FirstName=Justin&inf_field_LastName=Monty&inf_field_Email=test@yahoo.com&inf_option_Signmeupfortheibid2SAVEmailinglist=true&inf_field_LeadSourceId=14

It returns as Error 640 which I believe means all the input variables are not listed. However those are all the ones when I pull up the source code on the form page.

And it does need to be a post? I know that for sure. Shouldn't this code post it to my server?
 
Well I have made some progress... This is what I have got:

https: //MYPRIVATECODEHERE.infusionsoft.com/app/form/43b141428387198ba51d1a12abeeb800post?inf_form_xid=43b141428387198ba51d1a12abeeb800&inf_form_name=Standard CoReg Mail Form&infusionsoft_version=1.22.11.28&inf_field_FirstName=Justin&inf_field_LastName=Monty&inf_field_Email=test@yahoo.com&inf_option_Signmeupfortheibid2SAVEmailinglist=true&inf_field_LeadSourceId=14

It returns as Error 640 which I believe means all the input variables are not listed. However those are all the ones when I pull up the source code on the form page.

And it does need to be a post? I know that for sure. Shouldn't this code post it to my server?

I've never seen a 640, maybe a custom error code.

the text 'post' in your code above looks like it might be out of place:
43b141428387198ba51d1a12abeeb800post?inf_form_xid=

Is this value always the same? :
43b141428387198ba51d1a12abeeb800

I'm guessing this may change with the session and if it does, you'll have to change your post URL, unless you're always getting the HTML form from the server before posting and that hidden value inf_form_xid is already populated (and the form's 'action' attribute as well).

If you want to post it via curl, here's the general code to post a form and manage the cookies similar to how a web browser would:

Code:
$post_vars = array(
 //set up the vars here  'name'=>value,...
);

       function post_form($post_url, $post_vars){
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
         curl_setopt($ch, CURLOPT_COOKIEFILE, "/path/to/cookiejar2.txt");
         curl_setopt($ch, CURLOPT_URL,$post_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vars);
         $buf2 = curl_exec ($ch);
         
         curl_close ($ch);
         
         return $buf2;
}
the return value would be a string and would probably be the 'success' page if the form was accepted, or an error page. You may need to make some slight modifications to it, depending on how you're set up (look at curl SSL options).

ALso, if you don't have Web Developer Toolbar for Firefox, get it; when you open a form in the browser, you can get it to list all the form vars. And if you have Firebug, you can see the headers and what actually is getting posted.
 
On the code I posted above, I forgot you should first do a curl request to get the form page:

Code:
function get_form($form_url){
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
         curl_setopt($ch, CURLOPT_COOKIEJAR, "/path/to/cookiejar2.txt");
         curl_setopt($ch, CURLOPT_URL, $form_url);

         
         $str = curl_exec ($ch); // execute the curl command
         
         curl_close ($ch);
         return $str;
     }
then your cookie data would be in the cookie file and the form HTML as a string would be returned by the function. When I do stuff like this, I generally use the return value of this one to find the form vars and post URL, then pass it to the second function.
 
Just had a look at your script - made a couple of tweaks & it seems to work.
Hope I didn't miss the point completely...
there's a space in "inf_option_Signmeupfortheibid2SAVEmailinglis t"

All I did to get it to work was remove the space and add </form> at the end...