Trying to add a record; didn't think I was a newbie for reals.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to add a record; didn't think I was a newbie for reals.

Keith M. Rettig
Using Lasso 9.1.4 on Mac Os X Server 10.6.8 running Apache and FM Server 11.04.404
Apache has .lasso and .html set to pass to Lasso handler.

I am dying here with frustration.
Up front admission; I am moving (with great pain at the moment) from Lasso 3.6.5 on Webstar to above setup.


Why does this work perfectly (keithsautoadd.html)?

[inline( -database='dbname', -table='tablename', 'name_first'="Keith", 'name_last'="Rettig", -add )]
[records]
  [field:'name_first']
  [field:'name_last']
  [field:'ID']
[/records]
[/inline]

but this does not work (keithstestpage.html)?

<form action="keithssubmit.html" method="post" name="contactForm">
<input type="hidden" name="-database" value="dbname">
<input type="hidden" name="-table" value="tablename">
<input name="name_first" type="text" size="40" maxlength="40">
<input name="name_last" type="text" size="40" maxlength="40">
<input type="hidden" name="-add" value="">
<input type="submit" name="-add" value="Submit">
</form>

this is what is on keithssubmit.html

[records]
  [field:'name_first']
  [field:'name_last']
  [field:'ID']
[/records]

I get nothing.  No errors, no records added.  Page returns with no records returned.
Adding [Action_Statement] to keithssubmit.html returns nothing.

Thanks in advance.  I am sure it is something ridiculously simple. . .
Keith.
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Trying to add a record; didn't think I was a newbie for reals.

stevepiercy
You're confusing multiple methods of querying the database.  
Your former example is now preferred, the latter is deprecated.  
The latter was ambiguously called "Classic Lasso Syntax" where
database parameters could be passed to a file called action.lasso.

Assuming you have some method to prevent just anyone from adding
records to your database, here is a basic example.  Copy and
paste into a single file.  It's very crude and lacks specific
error handling and display of error messages, but it will get
you going.

[
var('input_valid' = false,
     'name_first' = action_param('name_first'),
     'name_last' = action_param('name_last'),
     'submit' = action_param('submit'));
// code to validate input and set $input_valid to true if it is valid
if($name_first != ''
     && $name_last != ''
     && $submit == 'Submit');
     $input_valid = true;
/if;
if($input_valid);
     inline(
         -database='dbname',
         -table='tablename',
         'name_first'=$name_first,
         'name_last'=$name_last,
         -add);
         if(error_code == 0);
             // inline action succeeded
             records;
                 field('name_first');
                 field('name_last');
                 field('ID');
             /records;
         else;
             // inline action failed
             // some debugging stuff
             error_currenterror;
             action_statement;
         /if;
     /inline;
]
<p><a href="[response_filepath]">Add another record</a></p>
[else]
     [if(!$input_valid && $submit == 'Submit')]
<h1>Data Not Valid</h1>
     [/if]
<form action="[response_filepath]" method="post" name="contactForm">
     First: <input name="name_first" type="text" size="40" maxlength="40">
     Last: <input name="name_last" type="text" size="40" maxlength="40">
     <input type="submit" name="submit" value="Submit">
</form>
[/if]

--steve


On 12/4/11 at 3:01 AM, [hidden email] (Keith Rettig) pronounced:

>Using Lasso 9.1.4 on Mac Os X Server 10.6.8 running Apache and FM Server 11.04.404
>Apache has .lasso and .html set to pass to Lasso handler.
>
>I am dying here with frustration.
>Up front admission; I am moving (with great pain at the moment)
>from Lasso 3.6.5 on Webstar to above setup.
>
>
>Why does this work perfectly (keithsautoadd.html)?
>
>[inline( -database='dbname', -table='tablename',
>'name_first'="Keith", 'name_last'="Rettig", -add )]
>[records]
>[field:'name_first']
>[field:'name_last']
>[field:'ID']
>[/records]
>[/inline]
>
>but this does not work (keithstestpage.html)?
>
><form action="keithssubmit.html" method="post" name="contactForm">
><input type="hidden" name="-database" value="dbname">
><input type="hidden" name="-table" value="tablename">
><input name="name_first" type="text" size="40" maxlength="40">
><input name="name_last" type="text" size="40" maxlength="40">
><input type="hidden" name="-add" value="">
><input type="submit" name="-add" value="Submit">
></form>
>
>this is what is on keithssubmit.html
>
>[records]
>[field:'name_first']
>[field:'name_last']
>[field:'ID']
>[/records]
>
>I get nothing.  No errors, no records added.  Page returns with no records returned.
>Adding [Action_Statement] to keithssubmit.html returns nothing.
>
>Thanks in advance.  I am sure it is something ridiculously simple. . .
>Keith.
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso
>[hidden email]
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>