Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  Annoying badmatch, undefined

Guest
Posted: Sun Oct 12, 2008 9:53 am Reply with quote
Guest
Hi guys

I have a form like this:

<form method="POST" action="/person/do_signup">

<b>My username:</b>
<input tabindex="1" type="text" name="username" id="username"
class="off" onfocus="this.className='on'"
onblur="this.className='off'" />
</div>
......
<input tabindex="7" type="submit">

That form posts to this controller:

-module(person_controller).
-export([do_signup/1]).

do_signup(A) ->
case yaws_arg:method(A) of
'POST' ->
....

For some strange reason, I keep getting this error when I submit the
form against the controller function:


ERROR erlang code crashed:
File: appmod:0
Reason: {{badmatch,undefined},
[{person_controller,do_signup,1},
{erlyweb,ewc,2},
{erlyweb,handle_request,6},
{yaws_server,deliver_dyn_part,8},
{yaws_server,aloop,3},
{yaws_server,acceptor0,2},
{proc_lib,init_p,5}]}
Req: {http_request,'POST',{abs_path,"/person/do_signup"},{1,1}}

Since I have exported the function correctly and accepting the right
number of parameters for the function, I am really stumped as to what
is going in here. Anybody care to explain to me?

Thanks
Nii Amon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Mon Oct 13, 2008 9:25 am Reply with quote
Guest
OK I "fixed" this.

For some reason, when I do:

yaws_api:queryvar(A, "username"),

erlyweb or yaws throws up about a badmatch. I thought that must have
been because the input was not in the yaws arg passed to the function
but a parse_post test I did showed that it was indeed in there. What I
did was to do a yaws_api:parse_post(A) and then use lists:keysearch to
pick up the relevant inputs.

Did I miss something here? How do people pick up POST parameters from
a request?

Nii Amon

On Oct 12, 9:53
Guest
Posted: Mon Oct 13, 2008 12:49 pm Reply with quote
Guest
On 10/13/08, nii amon <jazzyy@gmail.com> wrote:
>
> OK I "fixed" this.
>
> For some reason, when I do:
>
> yaws_api:queryvar(A, "username"),
>
> erlyweb or yaws throws up about a badmatch. I thought that must have
> been because the input was not in the yaws arg passed to the function
> but a parse_post test I did showed that it was indeed in there. What I
> did was to do a yaws_api:parse_post(A) and then use lists:keysearch to
> pick up the relevant inputs.
>
> Did I miss something here? How do people pick up POST parameters from
> a request?

This page explains that the queryvar(A, "key") form is applicable only
to the query portion of the URL:

<http://yaws.hyber.org/query.yaws>

If you want code that covers both the query portion of the URL as well
as POST data, then you got it right -- call yaws_api:parse_query(A) to
get a property list, and then use lists:keysearch, proplists:lookup or
proplists:get_value to look through it.

--steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Tue Oct 14, 2008 2:11 am Reply with quote
Guest
Yup. I glossed over that.

Thanks
Nii Amon

Steve Vinoski wrote:
> On 10/13/08, nii amon <jazzyy@gmail.com> wrote:
> >
> > OK I "fixed" this.
> >
> > For some reason, when I do:
> >
> > yaws_api:queryvar(A, "username"),
> >
> > erlyweb or yaws throws up about a badmatch. I thought that must have
> > been because the input was not in the yaws arg passed to the function
> > but a parse_post test I did showed that it was indeed in there. What I
> > did was to do a yaws_api:parse_post(A) and then use lists:keysearch to
> > pick up the relevant inputs.
> >
> > Did I miss something here? How do people pick up POST parameters from
> > a request?
>
> This page explains that the queryvar(A, "key") form is applicable only
> to the query portion of the URL:
>
> <http://yaws.hyber.org/query.yaws>
>
> If you want code that covers both the query portion of the URL as well
> as POST data, then you got it right -- call yaws_api:parse_query(A) to
> get a property list, and then use lists:keysearch, proplists:lookup or
> proplists:get_value to look through it.
>
> --steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Tue Oct 14, 2008 2:16 am Reply with quote
Guest
Steve,

There's actually yaws_api:postvar(A, PostVar) that works just like
queryvar: returns {ok, Val} for success and undefined for fails.

Nii Amon

Steve Vinoski wrote:
> On 10/13/08, nii amon <jazzyy@gmail.com> wrote:
> >
> > OK I "fixed" this.
> >
> > For some reason, when I do:
> >
> > yaws_api:queryvar(A, "username"),
> >
> > erlyweb or yaws throws up about a badmatch. I thought that must have
> > been because the input was not in the yaws arg passed to the function
> > but a parse_post test I did showed that it was indeed in there. What I
> > did was to do a yaws_api:parse_post(A) and then use lists:keysearch to
> > pick up the relevant inputs.
> >
> > Did I miss something here? How do people pick up POST parameters from
> > a request?
>
> This page explains that the queryvar(A, "key") form is applicable only
> to the query portion of the URL:
>
> <http://yaws.hyber.org/query.yaws>
>
> If you want code that covers both the query portion of the URL as well
> as POST data, then you got it right -- call yaws_api:parse_query(A) to
> get a property list, and then use lists:keysearch, proplists:lookup or
> proplists:get_value to look through it.
>
> --steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum