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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Help in getting $query->param()



Jun 30, 2000, 11:45 AM

Post #1 of 1 (678 views)
Help in getting $query->param() Can't Post

Please help me with this program
I want to add some text (location) in the textbox and when i submit the form, it should add location to the database and it should take me to a different form which also has the textbox and submit button. In 2nd form,When i add text (room) to the textbox and click the submit button, it should go to the same form and should add 'room' to the location that i entered in the first form. Since the submit button takes me to the same form i should be able to add to the same location (from first form) and room whatever is entered in the textbox(as a new record)to the database.
In other words,
In 2nd form,
the first time when i enter 'text', it should update 'text' to the 'location' from the previous form. The following entries to the text box should add a new record with the text in the textbox and the location from the previous form
I have update and add subroutines working.
Please help me organize the tasks.
I have 2 forms. form1.cgi and form2.cgi
print <<"html";
<form method = "post" action ="form2.cgi>
<input type ="textbox" name="location" size =10>
<input type ="submit" name="Add" value="Add location">
$value = $query->param('location');
if ($value) {
&add; #subroutine is working fine
#html for the second form (1 textbox and submit button)
<form method ="post" action="form2.cgi> #takes to the same form
print <<"html";
<input type="text" name="room" size=10>
<input type ="submit" name="addroom" value="Add Room">
$value1 =$query->param('room');
if ($value1){
&doupdate; it updates the record for the first time. (This is working)
I want to add a new record after the first entry. I have the &add subroutine working for inserting the data but i want to know how should i use the add subroutine to do the following inserts as a new records.

I am having one more problem. Everytime i click the submit button and call the subroutine for update or add, i am loosing the $query->param('location'). It is just inserting a room with null location.
If you take the above example, if i say,

$value1 =$query->param('room');
if ($value1){
&add; #this is adding a new record.
It is doing only once. Next time when the user enters 'text in the textbox, it is loosing the location.
THe following is the add subroutine, which adds room to the location in the previous form

sub add {
$value = $query->param('location');
$room = $query->param('room');
$insert = "insert into ConferenceRooms (location,room) values ('$value','$room')";
$sybHandle->execute() &#0124; &#0124; &writeError('room cannot be added');
$rc = $sybHandle->finish();
$message = "<b> room has been Added</b><p>";
How do i solve this problem.
Any help will be great.


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

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