Author Topic: Use original form for update  (Read 8329 times)

0 Members and 1 Guest are viewing this topic.

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Use original form for update
« on: December 13, 2006, 12:33:03 PM »
There are a lot of questions about how to use a customized form to update the DB.  Here is how you can use your original form and addapt it so use can use csvupdate to update your DB:

(NOTE: you can copy this code exactly as it is in order to play with it yourself.)

Original form:

Code: [Select]
<form method="POST" action="http://mydomain.com/cgi-bin/csvwrite.pl">
<table border="0" cellpadding="0" cellspacing="0" width="300" id="table6">
<tr>
<td style="padding: 1px; " width="80" align="right" valign="top">
<font face="Arial" size="2">Name</font></td>
<td style="padding: 1px; ">
<input type="text" name="name" size="20"></td>
</tr>
<tr>
<td style="padding: 1px; " width="80" align="right" valign="top">
<font size="2" face="Arial">E-mail</font></td>
<td style="padding: 1px; ">
<input type="text" name="email" size="20"></td>
</tr>
</table>
<p><input type="submit" value="Submit"><input type="reset" value="Reset">
</p>
</form>

Now here is the same form with the update feature:

Code: [Select]
<template>
<div align="center">
<form method="POST" action="http://mydomain.com/cgi-bin/csvupdate.pl">
<input type="hidden" name="ID" value="[[ID]]">
<input type="hidden" name="action" value="save">
<table border="0" cellpadding="0" cellspacing="0" width="320" id="table2">
<tr>
<td style="padding: 3px" width="125" align="right" valign="top">
<font face="Arial" size="2">Name:</font></td>
<td style="padding: 3px" width="225">
<input type="text" name="name" size="20" value="[[name]]"></td>
</tr>
<tr>
<td style="padding: 3px" width="125" align="right" valign="top">
<font size="2" face="Arial">E-mail:</font></td>
<td style="padding: 3px" width="225">
<input type="text" name="email" size="20" value="[[email]]"></td>
</tr>
</table>
<p><input type="submit" value="Submit"><input type="reset" value="Reset"></p>
</form>
</div>
</template>

A few things to keep in mind:

1.  Don't forget the template tags
2. Make sure you include the two hidden tags under the form tag in the update form.
3. Make a new template under the mytemplates section in csvread for your update form like "updateform"
4. When calling the update form, use csvread like this:
   http://mydomain.com/cgi-bin.csvread.pl?mytemplate=updateform&ID=1000000

You should have all the tools needed to simply make a customized update form!!

Jason
Founder of www.slipdex.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #1 on: December 13, 2006, 12:36:13 PM »
Sorry, one correction, I'm sure most of you caught...  when calling the form:

http://mydomain.com/cgi-bin/csvread.pl?mytemplate=updateform&ID=1000000

That's better!

Jason
Founder of www.slipdex.com

Offline tomrector

  • Newbie
  • *
  • Posts: 3
Re: Use original form for update
« Reply #2 on: February 19, 2007, 02:56:18 PM »
When I try this "tip"  My datafile updates but my browser automatically goes to the csvupdate.pl (Plotupdate.pl) address.  I want it to return the user to a desired page or the template call below.   
   
  Any direction I can get for why the page goes to the update pl address would be great.  If you want to see  for yourself, use the template call address below. It is in the test mode, I will change the file names when I get it to work correctly.

The update pl is standard except for file names
I call the template with http://www.375services.com/cgi-bin/PlotRead1.pl?order_by=ID&order=123

 My templaye text is:

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="898" height="119">
    <tr><template>
    <form method="POST" action="http://www.375services.com/cgi-bin/[[Reserved]]Plotupdate.pl">   
<input type="hidden" name="ID" value="[[ID]]">
<input type="hidden" name="action" value="save">
<input type="hidden" name="Reserved" value="RX">
 <td width="79" height="82">

         <input border="0" src="../odr/[[Reserved]]plot[[ID]].GIF" name="Plot" Value="Plot #1" width="71" height="60" type="image"></td>
    <td width="312" height="82">Name:
    <input type="text" name="Name" value="[[Name]]"size="41" style="background-color: #FFFFCC"><br>&nbsp;Email:  <input type="text" name="Email" value="[[Email]]" size="41" style="background-color: #FFFFCC"></td>
    <td width="114" height="82">DP<input type="text" name="DPH" value="[[DPH]]" size="12" style="background-color: #FFFFCC"> <br>HP<input type="text" name="HPH" size="12" style="background-color: #FFFFCC"></td>
    <td width="388" height="82">Credit Card&nbsp;
    <input type="text" name="CCard" "size="20" style="background-color: #FFFFCC" size="20"> Type:
    <select size="1" name="Type" style="background-color: #FFFFCC">
    <option value="Visa">Visa</option>
    <option value="Master">Master</option>
    <option value="Club">Club</option>
    </select><br>&nbsp;&nbsp;&nbsp;
    Exp Month <input type="text" name="XMnth" size="4" style="background-color: #FFFFCC"> Exp Year
    <input type="text" name="XYear" size="4" style="background-color: #FFFFCC"></td>
  </tr></form></template>
      </table>

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #3 on: February 19, 2007, 03:17:28 PM »
tom,

not sure what it is you are trying to do there.  I looked at the generated source. and can't see exactly what is going on.  You are using the RESVD image as your submit maybe?  in any event I cannot quite see how your form is submitting.  I see this for the image:

<input border="0" src="../odr/RXplot1.GIF" name="Plot" Value="Plot #1" width="71" height="60" type="image"></td>

You may want to try doing this with a plain submit button so you can get it working first, then add on to it.  it is a bit confusing what it is exactly you are trying to do.

Jason
Founder of www.slipdex.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #4 on: February 19, 2007, 03:30:29 PM »
Tom, also a few things to keep in mind.  It is not the best idea to start your ID's at '1' because everytime you call or search for an ID with one number you are going to pull multiple records, for example csvread.pl?ID=2...  in your case will pull not only record #2, but also #12, #20, #21 and so on.

The update hack was made mainly for pulling one record at a time, though it's possible to use it the way you are.  But my suggestion is to get the hack working on a single record form first, then try to mix in your own magic there.  Once you have an understanding of how it works you will probably be able to play with it how you want.

Try at the very least adding "value="Submit"" to your img tag if that is your submit function.  I am just getting a bit lost in the source.

And one final tip...  you may want to shut off highlighting in your csvread script in you use inlive style tags.  When it highlights it breaks the style tag string and displays it as text.  There is a way to fix that in the csvread script, but we will leave that for another time.

Jason
« Last Edit: February 19, 2007, 03:32:57 PM by Jason »
Founder of www.slipdex.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #5 on: February 19, 2007, 03:44:40 PM »
I just keep seeing stuff....

Apparently "http://www.375services.com/cgi-bin/RXPlotupdate.pl" is not your update script.  I poked around and you should be using "Plotupdate.pl", not RXPlotupdate.pl, I can only assume it's sliding it in the cuz you are using this:

http://www.375services.com/cgi-bin/[[Reserved]]Plotupdate.pl as your form action.

Jason
Founder of www.slipdex.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Use original form for update
« Reply #6 on: February 19, 2007, 04:26:12 PM »
Best guess is that there are a few things messed up here including the name of the script as well as if it's name matches in the script:

my $prog_name       = "csvupdate.pl";
my $base_file       = "database.txt";
my $HTML_thankyou   = 'thankyou.htm';
Uniting Bands
www.unitingbands.com

Offline keepahold

  • Newbie
  • *
  • Posts: 1
Re: Use original form for update
« Reply #7 on: May 21, 2007, 04:15:53 AM »
Just one thing to add after a morning playing with this hack trying to get this to work

If using a upload image/file you will need to add
ENCTYPE="multipart/form-data" needs to added to form

ie

<form method="POST" action="http://mydomain.com/cgi-bin/csvupdate.pl" ENCTYPE="multipart/form-data" >

Offline casi

  • Jr. Member
  • **
  • Posts: 34
Re: Use original form for update
« Reply #8 on: November 05, 2007, 09:05:54 AM »
This is absolutly great stuff. It solves the problem to use drop down menus when editing records! The only thing which is now missing is how to delete a record... Is there an easy way to add a delete button or link to that form? Thanks Casi

Offline casi

  • Jr. Member
  • **
  • Posts: 34
Re: Use original form for update
« Reply #9 on: November 05, 2007, 09:18:50 AM »
Just found a way to do it: simply use this bit of code: <input type="checkbox" name="ez_csv_delete_it" value="yes"> Thanks, Casi

Offline casi

  • Jr. Member
  • **
  • Posts: 34
Re: Use original form for update
« Reply #10 on: November 05, 2007, 11:47:28 AM »
One more thing: When there is html code set to 1 and thereis code in a field using quotes "" (example: <a href="xxxxx">), the original form is faulty. Using ' instead of " (example: <a href='xxxxx'>) then it works - is there a reason for this? Thanks Casi

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #11 on: November 05, 2007, 12:52:17 PM »
Casi,

The way the script and the template react to the html code is why. You can use quotes and single quotes interchangeably 99% of the time, as well as not using any quotes at all.

You could find yourself a javascript that will remove the quotes on submit, or even on display, but on submit would make more sense.  The use of single quotes can get sticky as well since a contraction can be used and mess up the code as well, like can't or don't for us US users of the scripts.

You best bet is to find a js that will remove the quotes from any submitted html enabled field.

Jason
Founder of www.slipdex.com

Offline shlomit

  • Hero Member
  • *****
  • Posts: 117
Re: Use original form for update
« Reply #12 on: October 16, 2011, 05:50:27 PM »

Hi
you helped a lot, i tried it and it awsom. one problem. in the text area I got all the <BR> signs. since this form is for customers to update their ads, it does not look good
any idea ?

thanks

Shlomit

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Use original form for update
« Reply #13 on: October 17, 2011, 03:13:05 PM »
Shlomit,

You could use a rich text editor. I use one call Open WYSIWYG. You can find it here:

http://www.dynamicdrive.com/dynamicindex16/openwysiwyg/index.htm

I use it in several projects, one of which you can find here:

http://www.slipdex.com/form.htm

What it will do is allow your user to input HTML styled text and view right on your webpage. It is just like using any word processing program on your computer, except it in all javascript browser side on your webpage. It works great and allows the user to style the text. Once you have it loaded you can actually disable certain buttons or do whatever you want. If you look at my project, you will see that I limit the options the user can use.

Jason
Founder of www.slipdex.com

Offline shlomit

  • Hero Member
  • *****
  • Posts: 117
Re: Use original form for update
« Reply #14 on: October 19, 2011, 05:59:45 PM »

Hi Jason

thanks, i will look for it , thanks :)

Shlomit