CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How to implement a checkbox that will send data to db

 

First page Previous page 1 2 Next page Last page  View All


Zhris
Enthusiast

Jul 16, 2014, 5:58 AM

Post #26 of 40 (1229 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi,

Could you show your template and CSS.

My guess though is you are referring to your source code and that the gaps are a result of newlines surrounding template tags, which become particularly messy when you have lots of conditions. If this is the case, there are lots of options for HTML::Template, one possibility is http://search.cpan.org/~mathew/HTML-Template-Bundle-2.9_01/lib/HTML/Template/Filters.pm#STRIP_TMPL_NEWLINE_WHITESPACE.

I don't use HTML::Template any more, eventually it wasn't able to support all my needs, instead I use Template Toolkit. You may eventually prefer to switch over.

Chris


(This post was edited by Zhris on Jul 17, 2014, 7:34 AM)


terrykhatri531
User

Jul 16, 2014, 6:22 AM

Post #27 of 40 (1226 views)
Re: [Zhris] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi Chris,

Here is the template, the css file is too big about 500 lines which I found on the internet which I tried to edit by adding:


Code
 
ul{
margin-bottom: 0;
padding-bottom: 0;
}







Code
 
<!-- Customers.tmpl -->
<html>
<head>
<title>Customers Listing</title>
</head>
<link type="text/css" rel="stylesheet" href="http://192.168.56.105/perlproj/cgi-bin/css/pagination2.css" />
<body text=#3300CC >
<h1 style="color:FF99CC;">Company's Customers Listing</h1>
<table cellpadding=5 cellspacing=0 border=1 bordercolor=pink>
<tr>
<th style="background-color:pink;">Customer ID</th>
<th style="background-color:pink;">Customer Name</th>
<th style="background-color:pink;">Contact Name</th>
<th style="background-color:pink;">Contact Title</th>
<th style="background-color:pink;">Address</th>
<th style="background-color:pink;">City</th>
<th style="background-color:pink;">Region</th>
<th style="background-color:pink;">Postal Code</th>
<th style="background-color:pink;">Country</th>
<th style="background-color:pink;">Phone</th>
<th style="background-color:pink;">Fax</th>
</tr>

<!-- TMPL_LOOP NAME=ROWS -->
<tr>
<td><!-- TMPL_VAR NAME=CustomerID --></td>
<td><!-- TMPL_VAR NAME=CompanyName --></td>
<td><!-- TMPL_VAR NAME=ContactName --></td>
<td><!-- TMPL_VAR NAME=ContactTitle --></td>
<td><!-- TMPL_VAR NAME=Address --></td>
<td><!-- TMPL_VAR NAME=City --></td>
<td><!-- TMPL_VAR NAME=Region --></td>
<td><!-- TMPL_VAR NAME=PostalCode --></td>
<td><!-- TMPL_VAR NAME=Country --></td>
<td><!-- TMPL_VAR NAME=Phone --></td>
<td><!-- TMPL_VAR NAME=Fax --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<hr>
Jumpt to : <ul class="tsc_pagination tsc_paginationA tsc_paginationA08">
<li><a href="addcust.pl">Add Customers</a></li>
<li><a href="editcust.pl">Edit Customers</a></li>
<li><a href="delcust.pl">Delete Customers</a></li>
</ul>

<hr>
Edited by Terry on July, 16 2014.

</body>
</html>


Many thanks !

Terry


FishMonger
Veteran / Moderator

Jul 16, 2014, 6:50 AM

Post #28 of 40 (1221 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

If you want help fixing the css, you'll need to post the css file (as an attachment) or at the very least post all of the relevant portions of the file that define the styling of the <ul> and <li> tags.

You should not hard code the style attributes in the tags. Instead use the id and class attributes and define the styling in the css file.


terrykhatri531
User

Jul 16, 2014, 7:07 AM

Post #29 of 40 (1219 views)
Re: [FishMonger] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi Chris and Ron,

the css file is attached.

Many thanks !!

Terry
Attachments: pagination2.css (20.8 KB)


FishMonger
Veteran / Moderator

Jul 16, 2014, 7:47 AM

Post #30 of 40 (1217 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Can you post a publicly accessible link to your page so that we can see the extra spacing you're referring to?


FishMonger
Veteran / Moderator

Jul 16, 2014, 8:09 AM

Post #31 of 40 (1212 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

I've attached a print screen of your page but I don't see any extra spacing after the <ul>....</ul> block.

IMO, the spacing between the links is a little too much but not extreme.
Attachments: terry.png (60.7 KB)


terrykhatri531
User

Jul 16, 2014, 8:27 AM

Post #32 of 40 (1209 views)
Re: [FishMonger] How to implement a checkbox that will send data to db [In reply to] Can't Post

Edut : Please see my png attached.

Hi Ron,

Thanks for your efforts but Its because your code is not linking with pagination2.css otherwise you would see those links in pretty hover over blue boxes not bulleted links.

Thanks

Terry


(This post was edited by terrykhatri531 on Jul 16, 2014, 8:52 AM)
Attachments: SpaceIssue.png (10.4 KB)


FishMonger
Veteran / Moderator

Jul 16, 2014, 8:50 AM

Post #33 of 40 (1203 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Ya, I forgot to double check the path I specified to the css file and due to the hard coding of the styling of the rest of the page, I didn't catch that error.

The <ul> block is loading 3 css definitions. If you load each one by themselves, you'll find that the problem is with the loading of the tsc_pagination {...} definition.

Specifically, it's the height:100%; portion of the definition that is causing the problem. Remove that and the problem goes away.


(This post was edited by FishMonger on Jul 16, 2014, 8:53 AM)


terrykhatri531
User

Jul 16, 2014, 9:01 AM

Post #34 of 40 (1200 views)
Re: [FishMonger] How to implement a checkbox that will send data to db [In reply to] Can't Post

Thanks a lot Ron for all your efforts you put into it, that did the job.

Thanks once again.

Rgds.

Terry


terrykhatri531
User

Jul 16, 2014, 5:17 PM

Post #35 of 40 (1184 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi guys,

I am trying to implement a photo upload routine using the following code which is resulting in an error as under :


Code
Permission denied at /usr/share/perlproj/cgi-bin/editphoto2.pl line 91.




And here is the relevant snippet of the script for uploading a photo :


Code
  
# get form parameters
my $q = new CGI;
my $action = $q->param('go');
my $empid = $q->param('empid');
my $upload_dir = "/usr/share/perlproj/cgi-bin/images";
my $filename = $q->param("photo");
my $safe_filename_characters = "a-zA-Z0-9_.-";
$CGI::POST_MAX = 1024 * 5000;

-----

# Upload photo
if ( $action eq "UPLOAD" ) {

if ( !$filename ) {
print $q->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}

my ( $name, $path, $extension ) = fileparse ( $filename, '..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;

if ( $filename =~ /^([$safe_filename_characters]+)$/ ) {
$filename = $1; }
else {
die "Filename contains invalid characters"; }

my $upload_filehandle = $q->upload("photo");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
binmode UPLOADFILE;


while ( <$upload_filehandle> ) {
print UPLOADFILE; }

close UPLOADFILE;

$msg = "Photo has been uploaded $upload_dir/$filename";
-----




The line in red is the offending one, the error msg is so brief its hard for me to guess what permission is being denied, but I am sure experienced gurus like you know what it means, the directory its being uploaded to has a -R 775 permission.

I am also attaching the whole script just in case you may want to have a look at it.

Many many thanks !!

Terry


(This post was edited by terrykhatri531 on Jul 16, 2014, 5:25 PM)
Attachments: editphoto2.pl (4.12 KB)


FishMonger
Veteran / Moderator

Jul 16, 2014, 5:44 PM

Post #36 of 40 (1180 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

When you receive a "Permission denied", you need to check the ownership and permission settings at each point in the path to verify that the script (or the web server user in this case) has the proper access rights to read/write the file.

Putting uploads into a directory under cgi-bin is not a destination choice and I'm pretty sure that's part of the reason for the problem you're seeing.


terrykhatri531
User

Jul 16, 2014, 6:46 PM

Post #37 of 40 (1173 views)
Re: [FishMonger] How to implement a checkbox that will send data to db [In reply to] Can't Post

Thanks Ron,

I changed the directory to /var/www/html/tmp and it works now, I see another issue now, later in my script I display the photo first before going ahead with the database update, that photo is not being displayed, here is the snippet :


Code
  

<form action="" method="post">
Select Employee name for photo update :<select name=empid>$options</select><br>
Enter full path with photo name :<input name="path" value="$upload_dir/$filename"><br>
<IMG SRC="$upload_dir/$filename" WIDTH ="350" HEIGHT="500" ALIGN="Right" BORDER ="10" BORDERCOLOR="#333"><br>
<input type="submit" class="tsc_c3b_large tsc_button tsc_c3b_blue tsc_c3b_input" name="go" value="UPDATE" />
</form>















Do you see anything wrong with the line in red, when I right click on the empty image it shows the right path and the name but there is no photo to see !

I gladly appreciate any help as I really don't have a clue why this is happening. Thank you.

Terry



(This post was edited by terrykhatri531 on Jul 16, 2014, 8:10 PM)


terrykhatri531
User

Jul 16, 2014, 11:34 PM

Post #38 of 40 (1155 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi Chris / Ron,

Here is the html source of the UPDATE action form which is supposed to show the image :


Code
Showing full path with photo name :<input name="path" value="/var/www/html/tmp/steven.jpg" readonly><br><IMG SRC="/var/www/html/tmp/steven.jpg" WIDTH ="350" HEIGHT="500" ALIGN="Right" BORDER ="10" BORDERCOLOR="#333"><br> 

<input type="submit" class="tsc_c3b_large tsc_button tsc_c3b_blue tsc_c3b_input" name="go" value="UPDATE" />


The update to the database goes through fine with the same path but for some reason the image itself is not being displayed.

Hope this helps !!

Many thanks !

Terry


FishMonger
Veteran / Moderator

Jul 17, 2014, 6:33 AM

Post #39 of 40 (1131 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Terry,

Please don't continue to add new issues/questions to this thread.

You need to start a new thread for this new issue and post your complete code, or at least enough of it for us to troubleshoot.


Zhris
Enthusiast

Jul 17, 2014, 7:33 AM

Post #40 of 40 (1110 views)
Re: [terrykhatri531] How to implement a checkbox that will send data to db [In reply to] Can't Post

Hi,

As FishMonger mentions, best to put new problems in new threads.

It looks as though you are once again using a path instead of URL, img tag / src attribute. I have never tested web code locally, but since this was the issue you were having with the stylesheet, I assume this is no different.

Regards,

Chris

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives