[dancer-users] Help with a POST

Andrew Solomon andrew at geekuni.com
Fri Aug 7 15:59:38 BST 2015


I think what you're after is something like this to tell the browser you
want to POST:

<form action="http://localhost:3000/user" method="POST">

Does that do the trick?

A

On Fri, Aug 7, 2015 at 3:47 PM, Richard Reina <gatorreina at gmail.com> wrote:

> Wait, Does this provide a clue to the error of my ways? This is the
> template (user.tt) that I am using for the form.
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <h1>Get in the game.</h1>
>
> <form>
> First name:<br>
> <input type="text" name="firstname">
> <br>
> Last name:<br>
> <input type="text" name="lastname">
> <br>
> Email Address:<br>
> <input type="text" name="email">
> <br>
> User Password:<br>
> <input type="password" name="psw">
> <br>
> User Confirm Password:<br>
> <input type="password" name="psw2">
> <br>
> Terms & Conditions
> <input type="checkbox" name="terms"> I agree with terms and conditions.<br>
> <br>
> <input type="submit" value="Go" />
> </form>
>
> <p>Note that the form itself is not visible.</p>
>
> <p>Also note that the default width of a text field is 20 characters.</p>
>
> </body>
> </html>
>
>
>
> 2015-08-07 9:36 GMT-05:00 John Stoffel <john at stoffel.org>:
>
>>
>> You need to build a web page with a FORM first, then submit the data
>> that way to the /user URL, so it can get handled.
>>
>> Try using git to clone this repository and use that as a base for your
>> playing around:
>>
>> https://github.com/agordon/dancer_bootstrap_fontawesome_template.git
>>
>> I don't have any working examples handy right this second...
>>
>> Richard> I am hoping someone can help me understand how to get this to
>> Richard> work as a POST instead of GET.  When I do sub below as 'get'
>> Richard> it works but when I replace 'get' with 'post' I get:
>>
>> Richard> --2015-08-06 13:52:05--  http://0.0.0.0:3000/user
>> Richard> Connecting to 0.0.0.0:3000... connected.
>> Richard> HTTP request sent, awaiting response... 404 Not Found
>> Richard> 2015-08-06 13:52:05 ERROR 404: Not Found.
>>
>> Richard> package MyApp;
>> Richard> use Dancer ':syntax';
>> Richard> use Dancer::Plugin::FormValidator;
>>
>> Richard> our $VERSION = '0.1';
>>
>> Richard> post '/user' => sub {
>>
>> Richard>    my $input_hash = {
>>
>> Richard>        FName => param('firstname'),
>> Richard>        LName => param('lastname'),
>> Richard>        Email => param('email'),
>> Richard>        Terms => param('terms'),
>>
>> Richard>    };
>>
>> Richard>    my $number_of_defined_values = scalar grep { defined } values
>> %{$input_hash};
>> Richard>    $number_of_defined_values = $number_of_defined_values + 0;
>>
>> Richard>    if ($number_of_defined_values > 1) {
>>
>> Richard>          my $error = form_validator_error( 'profile_user',
>> $input_hash );
>>
>> Richard>         if ( ! $error ) {
>> Richard>             #the user provided complete and validates data it's
>> cool to proceed
>>
>> Richard>         } else {
>>
>> Richard>              my %hash = %$error;
>> Richard>              foreach my $k (keys %hash) {
>> Richard>                  return "$k: $hash{$k}\n";
>>
>> Richard>              }
>>
>> Richard>         }
>> Richard>    }
>>
>> Richard>    template 'user';
>>
>> Richard> ##########################################################
>> Richard> }; ### end of sub user ###################################
>>
>> Richard> true;
>>
>> Richard> Thanks in advance for any help.
>>
>> Richard> _______________________________________________
>> Richard> dancer-users mailing list
>> Richard> dancer-users at dancer.pm
>> Richard> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>> _______________________________________________
>> dancer-users mailing list
>> dancer-users at dancer.pm
>> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>


-- 
Andrew Solomon

Mentor at Geekuni http://geekuni.com/
http://www.linkedin.com/in/asolomon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150807/929d12fd/attachment.html>


More information about the dancer-users mailing list