Forum Moderators: open

Message Too Old, No Replies

Is it possible to use 1 form to run 2 scripts?

         

KG2RG

9:43 pm on Mar 24, 2002 (gmt 0)

10+ Year Member



Is it possible to use 1 form to run 2 scripts? Example: Getting a users info and have one script email the info and another script set a cookie? I have included a sample of how I think it would be done if possible.


<form method="post" action="/url_path/mail.cgi">
<form method="post" action="/url_path/cookies.cgi">
<table border=1 bgcolor="#F5F5F5">
<tr><td><b>Full Name:</b></td>
<td><input name=full_name></td></tr>
<tr><td><b>Email:</b></td>
<td><input name=email></td></tr>
<tr><td><b>your site's contact e-mail address:</b></td>
<td><input name=sitecontact></td></tr>
<tr><td><b>Address1:</b></td>
<td><input name=address1></td></tr>
<tr><td colspan=2><input type=submit value="SUBMIT"></td></tr>
</table>
</form>

Damian

10:16 pm on Mar 24, 2002 (gmt 0)

10+ Year Member



I don't think you can have two 'actions' in a form.

As one script will have to set a cookie in your example it is not possible to call a third cgi script to invoke the other two (cookie particular)...so I think cookies.cgi would have to be adapted to invoke mail.cgi or vice versa.

So in the form the action would be cookies.cgi, but you also pass the variables needed for mail.cgi. Then cookies.cgi does it's thing and just before it exits it starts mail.cgi...

Would that work for you ?

KG2RG

12:03 am on Mar 25, 2002 (gmt 0)

10+ Year Member



So I should incorporate the cookie script in the top portion of the mail script, like right under the shebang. Instead of 2 scripts, it would be one script, a cookie & form mailer script.

This sounds good. I'll try it, thanks!

IanKelley

11:49 pm on Mar 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No reason to do that... Better to keep your code modular.

Instead, convert cookies.cgi into a library (basically just turn it into a function/group of functions) and then use "require" to include it in any script that needs it. You then call the function(s) you need from cookie.cgi directly after the require line.

This will save you a lot of time in the future.