473,378 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ButtonClick in CGI

savanm
85
Expand|Select|Wrap|Line Numbers
  1. #! c:/perl/bin/perl.exe
  2. use CGI qw(:standard);
  3. use DBI;
  4. use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
  5. $dbh = DBI->connect("DBI:mysql:database=perldbi;host=localhost","root","");
  6. $sth = $dbh->prepare('select * from foo1');
  7. $sth->execute();
  8. print header;
  9. print start_html('Newgen');
  10. print h1("DBI SAMPLES");
  11. print "User NAME:    <input type='text' name='user'><br>";
  12. print "<input type='button' value='Login' name='login'>";
  13. if($sth->rows == 0) {
  14.     #print "No information for " . $R:lace;
  15.  
  16. } else {
  17.     print "<table border=2>\n";
  18.     while( $resptr = $sth->fetchrow_hashref() ) {
  19.         print "<tr>";
  20.         print "<td>" . $resptr->{"usrid"};
  21.         print "<td>" . $resptr->{"pass"};
  22.         print "\n";
  23.         print "<\/tr>";
  24.     }
  25.     print "</table>\n";
  26. }
  27.  
  28. $dbh->disconnect;
  29. print end_html;
  30.  
Hi i have a code like that,

For this I have One Textbox and Button

IF am enter the values in that textbox and when am clicking that button,

The particular record in the text box must be insert into the tables.

ThanX
Apr 5 '07 #1
4 1750
KevinADC
4,059 Expert 2GB
I can't help much with the database part of your question, but the <input type=button> tag will not send data back to your script, use an <input type=submit> button.
Apr 5 '07 #2
savanm
85
Hi Kevin,

I will use <input type="submit"> instead of <input type="button">

So please Give me a further way to solve this problem

Thanx
Apr 6 '07 #3
KevinADC
4,059 Expert 2GB
Hi Kevin,

I will use <input type="submit"> instead of <input type="button">

So please Give me a further way to solve this problem

Thanx

Sorry my database skills are minimal.... to say the least. I can't help with that part your question.
Apr 6 '07 #4
savanm
85
Hi all,

Expand|Select|Wrap|Line Numbers
  1. #! c:/perl/bin/perl.exe
  2.  
  3. use CGI qw(:standard);
  4. use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
  5. use DBI;
  6.  
  7. use strict;
  8.  
  9. my $dbh = DBI->connect("DBI:mysql:database=perldbi;host=localhost","root","");
  10. my $sth = $dbh->prepare('select * from test');
  11. $sth->execute();
  12.  
  13. print header;
  14. print start_html('Newgen Imaging Systems(P) Ltd.,');
  15. $dbh->do("insert into test values('nav','hai')");
  16. print h1("Hello world");
  17.  
  18. if($sth->rows == 0) {
  19.     print h1("YES");
  20.  
  21. } else {
  22.     print h4("This is available table\n");
  23.     print "<table border=2>\n";
  24.     while(my $resptr = $sth->fetchrow_hashref) {
  25.         print "<tr>";
  26.         print "<td>". $resptr->{"name"};
  27.         print "<td>". $resptr->{"pass"};
  28.         print "\n";
  29.         print "<\/tr>";
  30.     }
  31.     print "<\/table>\n";
  32. }
  33. print "<br><input type='text' name='usrtxt'>";
  34. print "<br><input type='text' name='passtxt'>";
  35. print "<br><input type='submit' name='logbtn' value ='Insert' OnClick='Insert()'>";
  36. print "\t\t";
  37. print "<input type='submit' name='logbtn' value ='Clear'>";
  38.  
  39. $dbh->disconnect;
  40. print end_html;
  41.  
  42. #function Insert(){
  43.     #$d = $dbh->do("insert into test values('nav','hai')");
  44. #}
  45.  
I have a code like that

For that i want to insert a element in the textbox to database when

the button is clicked

Thanx in advance
Apr 7 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Denzen Stupilla | last post by:
hi all, I have a asp.net webform with textboxes and buttons. What's the trick to disabling the button on-click events to fire when Enter key is pushed? i want the server click events for the...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
1
by: Vinod I | last post by:
Hi Team, I want execute "Onclick" event whcih will trigger to a ClientSide Validation Javascript and once that over, should call Server side Button_Click(). Please let me know how to do this...
1
by: Joshua Weir | last post by:
Hi there, I just found out that when I have a button on an aspx page and i click it, the page_load event function executes before the button click event function. Why is this so? I have a web...
4
by: Boonaap | last post by:
Hi, I have this asp.net application in which the user can choose between three possible languages. NL - FR - EN How can I set the System.Globalization.CultureInfo to three different values,...
0
by: gce | last post by:
Hi, I have a aspx that I like to show the session("tfm") in a label on page_load. The value that is shown then is the old (initial value and not the updated value). When I make a button and the...
4
by: Brian Mitchell | last post by:
How do you fire a toolbar ButtonClick event manually (for a specified button)? I have a toolbar with 4 buttons on it and I want to fire one of the button events when the user clicks a different...
1
by: Jack | last post by:
Hi, How can I get my content page to repond to the button click it's Master page? Thanks, Jack.
2
by: Michael Moreno | last post by:
Hello, In a Base Form I have a toolbar and have implemented the Click event as: protected virtual void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)...
17
by: Arpan | last post by:
When a Button is clicked in a Web Form in an ASPX page, the Form will post back to itself. Under such circumstances (i.e. when a Button is clicked), will the Page_Load sub execute first & then will...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.