473,668 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ButtonClick in CGI

savanm
85 New Member
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 1760
KevinADC
4,059 Recognized Expert Specialist
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 New Member
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 Recognized Expert Specialist
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 New Member
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
1282
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 buttons to fire ONLY when the button is clicked with the mouse. thanks so much. Denzen
4
3407
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 write and it works fine until she puts it into a function and then calls the function from a button with onClick. This also seems to work OK, with the exception that the page is cleared, and the curser changes (and stays) as an hourglass. In...
1
1122
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 for a Server side Button Control. Thanks in advance Cheeeeeeeeeers !!
1
1615
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 form that is continually displayed. Each time the button is clicked i want the value of a checkbox to be checked and then i want the checkbox to be cleared when the page is reloaded. The problem is that i thought i would clear the checkbox in the...
4
1444
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, just by clicking a button? in a pageLoad i have something like this: switch(vLang){
0
931
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 same lines of code in the click event the current session("tfm") is show correctly. So the sessionvar is good but in page_load the old value is show. Please help.
4
3286
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 button on the form. The event for the toolbar looks like this... Private Sub tbUsers_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
1
1341
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
4612
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) { if (e.Button == tbClose) Close();
17
2837
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 the Click event function of the Button execute or will the Click event function of the Button execute first & then will the Page_Load sub execute? Thanks, Arpan
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8572
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2782
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.