Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

post url with 2 input

by bigup401 (Scribe)
on Jun 23, 2017 at 09:34 UTC ( #1193338=perlquestion: print w/replies, xml ) Need Help??
bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

how can i make url post with input choices

<input $1> <input $2>

how can i make it in url to either take input1 or input2

post => http://link/take input $1 or input $2

Replies are listed 'Best First'.
Re: post url with 2 input
by marto (Bishop) on Jun 23, 2017 at 09:41 UTC

      lets say

      $input1 = $cgi->param() $input2 = $cgi->param()

      and i want to make url post

      post => http://link.com/?num=either1 $input or $input2

        I'd probably start by suggesting that you write using Mojolicious::Lite rather than CGI in future, since it makes all this stuff easier with the Mojo modules. Regardless my previous answer suggests looking at the docs for LWP::UserAgent, the post() method which provides a working examples for exactly what you want to do. If you want to use a tool, read and understand the manual.

Re: post url with 2 input
by hippo (Abbot) on Jun 23, 2017 at 09:41 UTC
Re: post url with 2 input
by scorpio17 (Abbot) on Jun 23, 2017 at 13:23 UTC
    You can't "or" inputs within the url. You'll have to submit BOTH, and then the backend script that handles the request can implement whatever logic you require (i.e., check each input field for valid values, etc).
Re: post url with 2 input
by sundialsvc4 (Abbot) on Jun 23, 2017 at 14:24 UTC

    Specifically, this is an HTML <form> having two <input> boxes, each having distinct names, that are rendered side-by-side.   When the user enters data into one or both fields and then presses some kind of “submit” button (or, the form submits itself using JavaScript), the values in one or both fields will be included in the HTTP GET or POST stream that is sent to the server.   You should also be aware that the value will be sent only if it is not-empty and if it has changed.   (Easily the best way to see this is to use the debugging capability of any browser which will let you see the HTTP exchange that takes place.   Create a form, type something, hit the submit-button, and watch.   Or, check out the web-page referred-to below.)

    When the data arrives on the host side and is processed by Perl, anything that is actually present in the stream can be retrieved using its name.

    Now, having said all of this, this really is more of an HTML question than strictly a Perl one.   Although server-side languages vary, the fundamentals of what they’re dealing with are not, and this question appears to mostly concern those fundamentals.   Therefore, may I suggest that you spend time at http://www.w3schools.com where a very large amount of good tutorial information is presented in the form of online web tutorials.   (They include interactive forms that allow you to “try it,” and to immediately see the result.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1193338]
Approved by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2017-10-20 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?