mitchberry Posted November 23, 2009 Share Posted November 23, 2009 [[[[[[[ How to submit a form WITHOUT taking action on a button click and WITHOUT using CURL OR Javascript??? ]]]]]]]]]] Hi.. So I have an interesting problem that is going to take a little bit of effort to explain. Please bare with me. I have a CRM that allows web to lead campaigns... the problem is, the CRM is part of a phone system, therefore no one here would be familiar with it. With this system, it is possible to do “Web to Campaign.” Basically, you put a form on your website, someone fills it out, and it posts to a specified address via “GET” then processes the information, posts the new “lead” to the call list for the employees to call. Here’s the thing though. Typically when making a contact form, I would have a form that posts to a second file once the info is filled and the submit button has been clicked (or posts to self depending). The second file would say “if this is blank then say that, if this is that way then do this, etc etc etc etc… You know……. Like NORMAL… But the problem is, I don’t really have that capability with this. I make a form, they fill it out, hit submit, then it passes the info to the post URL that they provide and IT does all of the work. -but NO error handling-. What I NEED is, when a client fills out the form, hits submit, MY code will say “if this is blank throw an error, if the state is Lower case, make it upper case before sending it, if there are “-“ in the phone number, take them out and eliminate the spaces etc etc etc etc etc etc etc THEN…. If everything is OK…… post it to this URL that is specified by that company. In other words <form method=”post” action=”validate.php”> <input ---- form stuff Form stuff Form stuff [submit button] </form> Then they click the submit button $name = $_POST[‘name’]; (etc etc) If this happens then that, if that happens then this, if everything is CORRECT ----POST to URL provided by our web to campaign company…… ---------------------------- DOES WHAT IT DOES ---------------------------- Does that make sense at all? FYI… I know how to do everything BUT post without making someone take action on a button… they WILL need to hit submit the first time... then it goes through my error handling code, and THEN gets sent to the Post URL they specify.. This is what the form does currently. At the bottom, I put a “spry” text area that will throw an error if it isn’t filled out. (for testing purposes) The problem is, IF JAVASCRIPT IS TURNED OFF ON THE CLIENT MACHINE THEN IT DOES NOT WORK. The other thing is, if ANYTHING is entered into the form incorrectly, we will not get the lead, and it will not TELL THEM that it was not successful. So… that is the reason I need this to be done in PHP. what i have currently is JUST a form... and it works as such... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body> <?php $user_ip = $_SERVER['REMOTE_ADDR']; $client_date_entered = date("m-d-Y h:i:s a"); ?> <form id="form1" name="form1" method="get" action="https://(blah blah blah).com/web2campaign/AddToList"> <input name="F9domain" type="hidden" value="DRI1" /> <input name="F9list" type="hidden" value="from_web" /> <input name="F9retResults" type="hidden" value="1" /> <input name="F9retURL" type="hidden" value="http://www.mywebsite.com/Web2Campaign/index.php" /> <input name="IP" type="hidden" value="<? echo"$user_ip"; ?>" /> <input name="submit_dateTime" type="hidden" value="<? echo"$client_date_entered"; ?>" /> <input name="SourceID" type="hidden" value="P1" /><!-- P1 refers to the page that this information came from physically. --> <input name="lead_provider" type="hidden" value="LP2A" /> <input name="F9CallASAP" type="hidden" value="1" /> <table width="600" border="0"> <tr> <td>First Name</td> <td><input type="text" name="first_name" /></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="last_name" /></td> </tr> <tr> <td>Phone (no spaces)</td> <td> <input type="text" name="number1" id="number1" maxlength="10" size="10" /> </td> </tr> <tr> <td>City</td> <td><input type="text" name="city" /></td> </tr> <tr> <td>State</td> <td><input type="text" name="state" /></td> </tr> <tr> <td>Zip</td> <td><input type="text" name="zip" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Debt Amount</td> <td><input type="text" name="debt_amount" /></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <span id="sprytextfield1"> <input type="text" name="whatever" id="whatever" /> <span class="textfieldRequiredMsg">A value is required.</span></span> <script type="text/javascript"> <!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); //--> </script> <input name="submit" type="submit" value="submit" /> </form> </body> </html> All of that was basically to ask how to post the second time without having them hit submit twice....... I have never made something submit without a submit button. Thanks in advance.. Quote Link to comment https://forums.phpfreaks.com/topic/182709-how-to-post-to-a-url-without-taking-action-on-a-button-using-curl-or-using-js/ Share on other sites More sharing options...
Psycho Posted November 23, 2009 Share Posted November 23, 2009 Maybe I missed it, but why can't you use CURL? Seems the best solution to me. Quote Link to comment https://forums.phpfreaks.com/topic/182709-how-to-post-to-a-url-without-taking-action-on-a-button-using-curl-or-using-js/#findComment-964353 Share on other sites More sharing options...
mitchberry Posted November 23, 2009 Author Share Posted November 23, 2009 it is not supported on my web server, and i know there's another way around it. that and, maybe i misunderstand curl, but... curl allows you to log into various websites and make use of various things within it, therefore, i would be logging into the other page and making use of IT to do this stuff... thing is, i have -0- access to the page that things post to currently. it's on the other company's server and is a general script that is used for all of their clients (us and hundreds of other companies), so i can't alter anything within it.. basically, i can take water to a wall in a bucket, and i can throw the bucket of water over wall, but.. i will never know where it's landing, or what happens to it when i do.... it just... does what it does... and i need to do all of my validation prior to posting to that url... then... post to that url without using a second button. -using GET- instead of post. Quote Link to comment https://forums.phpfreaks.com/topic/182709-how-to-post-to-a-url-without-taking-action-on-a-button-using-curl-or-using-js/#findComment-964355 Share on other sites More sharing options...
mitchberry Posted November 23, 2009 Author Share Posted November 23, 2009 curl opens another page, and pulls the info from that page like a reverse post it seems like. i need to post from file A to file B,. then from B to URL.... meanwhile i am studying up on curl since i really have no idea what it is.. i just know it's not supported.... Quote Link to comment https://forums.phpfreaks.com/topic/182709-how-to-post-to-a-url-without-taking-action-on-a-button-using-curl-or-using-js/#findComment-964373 Share on other sites More sharing options...
Psycho Posted November 23, 2009 Share Posted November 23, 2009 If cURL isn't supported, then yes you cannot use it. But, just to prevent confusion, cURL does support POST. The "common" use of cURL is to log into another site from the back-end, but it has many different types of uses for interacting with other sites. From the manual PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication. Quote Link to comment https://forums.phpfreaks.com/topic/182709-how-to-post-to-a-url-without-taking-action-on-a-button-using-curl-or-using-js/#findComment-964376 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.