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:
Please help me in insert statement

 



datlaravi
Deleted

Jun 6, 2000, 12:42 PM

Post #1 of 5 (607 views)
Please help me in insert statement Can't Post

Hi,
I want to get the form value and insert into
the database. The html for the formfield is
for example
//file work.cgi
use CGI;
$query = new CGI;
$building =$query->param{'buildName'};
&printform;
sub printform {
<form name ="build" method ="post" action="work.cgi"> (same file has sub routines)

<TD> <input type="text" size="10" name="buildName"></TD>
<TD> <input type ="submit" name = "buildAdd" value ="BAdd">
}
The code i have is
if (($in{buildAdd} eq "BAdd")) {

&addBuilding;
}

sub addBuilding {
$insert = "insert ConferenceRooms values ('$building', "a123", 234, 0,0,0,0,0,"234-567-7890","345-346-8798")";
$sybHandle=$syb->prepare($insert);
$sybHandle->execute() &#0124; &#0124; &writeError('User cannot be added');
$sybHandle->finish();
#$message = "<b>User Added</b><p>";
}
I am getting an error at the insert statement.Please help me. Can you send me an email so i can send as an attachment.
Can i have 2 submit buttons in the same form with the post method going to the same file (eg: work.cgi)


dws
Deleted

Jun 6, 2000, 8:56 PM

Post #2 of 5 (607 views)
Re: Please help me in insert statement [In reply to] Can't Post

Try "insert into ConferenceRooms ..."

Also check your quotes. You either need to escape some of the double quotes or use single quotes.


[This message has been edited by dws (edited 06-06-2000).]


CuzDesign
Deleted

Jun 8, 2000, 1:54 AM

Post #3 of 5 (607 views)
Re: Please help me in insert statement [In reply to] Can't Post

Hello,
In answer to the following question:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
Can i have 2 submit buttons in the same form with the post method going to the same file (eg: work.cgi)
<HR></BLOCKQUOTE>

Yes you can use more then one submit to go to the same program, however you need to use them both seperate in there own form tags.

Also in your program if each of the "Submit" buttons is to run different parts of the program you need to check and see which part of the program to run, such as this.

If "Submit" button 1 is clicked, then go to and do sub submit1{}.

If "Submit" button 2 is clicked go to and do sub submit2{}.

Now you should use an action input tag to tell your program what you are trying to do and then test it when the program is called.

Example:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$action = param('action');
if ($action eq 'sub1') { &submit1 }
elsif ($action eq 'sub2') { &submit2 }
</pre><HR></BLOCKQUOTE>

Basically that says if the input tag actions value is "sub1" go to and do sub submit1 and the same for sub submit2.

This way you could put 2 or more forms on one page that do 2 different things using the same program.

Hope this helps.

Regards,
Ray


datlaravi
Deleted

Jun 8, 2000, 6:29 AM

Post #4 of 5 (607 views)
Re: Please help me in insert statement [In reply to] Can't Post

Thanks for your help. It works.


monocle
User

Jun 8, 2000, 7:14 AM

Post #5 of 5 (607 views)
Re: Please help me in insert statement [In reply to] Can't Post

 <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>
Yes you can use more then one submit to go to the same program, however you need to use them both seperate in there own form tags.
<HR></BLOCKQUOTE>
Actually you can have multiple submit buttons in the same form tag. You are correct though in speaking of the need to evaluate the buttons to see which action is meant to be done but you will need to test the name or the value(caption) of the button.

Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle


[This message has been edited by monocle (edited 06-08-2000).]

 
 


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

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