Page 1 of 1

submit multiple updates at once.

Posted: Mon Jan 27, 2003 8:59 pm
by ckwall
I have the following page built. Can I create one last update button that will run all of the update buttons?

<html>

<FORM NAME="fa" ACTION="spences_corner.php" METHOD="POST">
<B>Spences Corner:</B><br>
<TEXTAREA NAME="Spences_Corner" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

<FORM NAME="fa" ACTION="today_in_lex.php" METHOD="POST">
<br><B>Today in Lex:</B><br>
<TEXTAREA NAME="Today_in_Lex" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

<FORM NAME="fa" ACTION="general_announcements.php" METHOD="POST">
<br><B>General Announcements:</B><br>
<TEXTAREA NAME="General_Announcements" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

</html>

Posted: Tue Jan 28, 2003 12:14 am
by TheIceman5
to begin with you will have to rename them forms, you cant have 3 forms with the same name if you want to update the 3 at once.
Just use a function that has 3 submits in it called by your last button.
Just noticed the forms are submitting to 3 different pages, why? what happens after you press update button? does code run that updates a database or something? if so why dont you just use 1 script for that.

Posted: Tue Jan 28, 2003 7:28 am
by ckwall
These are all going to different locations of a company intranet. I guess I could use a database, but I have not learned how to do this yet. These each are going to a text file and then added to the intranet site as server side included files.

Let me try out your suggestion real quick. Thanks.

Posted: Tue Jan 28, 2003 7:32 am
by ckwall
OK, I am lost. How to I set the function up with multiple submits? How does it specify what it is updating?

Maybe provide an example.

Posted: Thu Jan 30, 2003 1:15 am
by TheIceman5
well im lost at what your trying to acheive here, it seems you are going about this thing very difficultly. If you press the first update button it calls spences_corner.php, what does this do from here? theres no actions specified anywhere.

go have a read of this tutorial on MySQL databses and forms, its a pretty good tut for beginners, tells you everything step by step in detail.
http://hotwired.lycos.com/webmonkey/pro ... rial4.html

Posted: Thu Jan 30, 2003 7:37 pm
by ckwall
Actualy what this is doing is sening the text in the text field to a text file. I do not have the luxury of using mysql. It is not supported by the server I am hosting on.

I have learned however that I should have writen these scripts differently. Using else. I cannot figure out the right way to do that.

These three fields are use individualy by people in my office to update a portion of an intranet site. I would just do one update, but unless all three boxes have text, the empty boxes over-write the text that should be there. So I need to have a script that does something to the effect that if there is text in the box, update, then move on to the next box and do the same, but if there is no text in the box, do not update it. then move on to the next and do the same.

Posted: Fri Jan 31, 2003 2:18 am
by Redcircle
I agree with iceman when he says rename the form name
ex

<FORM NAME="fa" ACTION="spences_corner.php" METHOD="POST"> would be <FORM NAME="spencers_corner" ACTION="spences_corner.php" METHOD="POST">

<FORM NAME="fa" ACTION="today_in_lex.php" METHOD="POST"> would be <FORM NAME="today_in_lex" ACTION="today_in_lex.php" METHOD="POST">

and

<FORM NAME="fa" ACTION="general_announcements.php" METHOD="POST"> would be <FORM NAME="general_announcements" ACTION="general_announcements.php" METHOD="POST">

Posted: Fri Jan 31, 2003 7:21 am
by ckwall
OK, I have made that change. Now how do I call all three forms to update?

<html>

<FORM NAME="spences_corner" ACTION="spences_corner.php" METHOD="POST">
<B>Spences Corner:</B><br>
<TEXTAREA NAME="Spences_Corner" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

<FORM NAME="today_in_lex" ACTION="today_in_lex.php" METHOD="POST">
<br><B>Today in Lex:</B><br>
<TEXTAREA NAME="Today_in_Lex" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

<FORM NAME="general_announcements" ACTION="general_announcements.php" METHOD="POST">
<br><B>General Announcements:</B><br>
<TEXTAREA NAME="General_Announcements" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
</FORM>

</html>

Posted: Sun Feb 02, 2003 12:47 am
by Oleg Butuzov
why 3?
you can do this by 1 form =)

Posted: Mon Feb 03, 2003 7:05 am
by WiZARD
Hi!
Maby the best if you collect from page all info in variable and in next page simply send at pages all info?

Posted: Mon Feb 03, 2003 8:47 am
by ckwall
Ok, i see what you are all saying. I just dont know how to do it. Can someone walk me through this or provide an example. This is the first script that I have ever written, I honestly dont know how i did it.

Posted: Mon Feb 03, 2003 10:56 am
by pootergeist
One form, one action, three fields sent...

<form action="update_files.php" method="post">
<B>Spences Corner:</B><br>
<TEXTAREA NAME="Spences_Corner" ROWS=5 COLS=40></TEXTAREA>
<br><B>Today in Lex:</B><br>
<TEXTAREA NAME="Today_in_Lex" ROWS=5 COLS=40></TEXTAREA>
<br><B>General Announcements:</B><br>
<TEXTAREA NAME="General_Announcements" ROWS=5 COLS=40></TEXTAREA>
<INPUT TYPE="submit" VALUE="Update">
<input type="submit" value="update filled fields" />
</form>

update_files.php
----------------
if(isset($_POST['Spences_Corner']) && $_POST['Spences_Corner'] !== "")
{
// spences corner textarea filled - process
$f = fopen('spences.txt',"w");
fwrite($f,$_POST['Spences_Corner']);
fclose($ff);
}

if(isset($_POST['Today_in_Lex']
etc etc

---------------------

You could get away with iterating the _POST array if the file names reflected the form field names - gets a lil more complicated though, so might be best to hardcode each process for the time being.

Posted: Mon Feb 03, 2003 4:10 pm
by ckwall
So if I understand the update_files.php correctly, this will only update if there is text entered into the box, correct? I would then do an entry for each field just like the one in the example. Right?