Thanks.
event after form submit completion?
Moderator: General Moderators
event after form submit completion?
Is there any such event that can do something after the form submit is finished?
Thanks.
Thanks.
Re: event after form submit completion?
What do you mean by "finished"?
Re: event after form submit completion?
requinix wrote:What do you mean by "finished"?
onAfterSubmit ? onCompletion ?
I have a form which insert a book information into database, but not the image.
The image is copied into the directory. Only after the book record is created I can insert the image into that record.
Therefore, I need to do something onCOmpletion
Re: event after form submit completion?
Okay... How about this: does submitting the form reload the page?
Re: event after form submit completion?
yes, reload.requinix wrote:Okay... How about this: does submitting the form reload the page?
So, you suggest to use onreload? But that might happen at other condition.
Could I put the function just after the table?
<table...>
</table>
function to be excuted on completion;
Last edited by wvoyance on Fri Apr 27, 2012 3:39 am, edited 1 time in total.
Re: event after form submit completion?
There is no such thing as an "onreload" event.
You can't have code on one page affect a later page. It's a pretty fundamental concept in JavaScript. So much so that I've never even seen it stated anywhere.
So the form allows for creating book records. Why not have the image upload there too and only run that code once the book has been created?
Also, and I'm just taking a guess here, but I bet your "only after the book record is created" statement isn't quite true. I bet you could do it at the same time, or with one or two statements immediately after.
You can't have code on one page affect a later page. It's a pretty fundamental concept in JavaScript. So much so that I've never even seen it stated anywhere.
So the form allows for creating book records. Why not have the image upload there too and only run that code once the book has been created?
Code: Select all
<?php
if (form was submitted) {
insert new book record;
add the image to the record;
etc;
}Re: event after form submit completion?
You asked a good question!
Perhaps I did something stupid.
The code was part of OSCommerce, which you might know.
Let me post them
http://pastebin.com/uGddv7wZ
This is the categories.php which administrator need to fill the form and put the products to the shop.
However, I want to built a book store which need at least 100000 products, cannot put by hand.
Therefore I wrote a program the administrator only need to enter ISBN (products number) and price.
The program will get other information (title, author...etc) from other libraries, and the products image.
The problem is products information is text while image is jpg file.
They are handled differently.
I used javascript AJAX call to server to send_one_isbn.php
http://pastebin.com/afB49Zya
This program copy the image and other information.
The "other information" is transmitted back the fill out the form, but image cannot.
Firstly, I don't know how to transmit image file back. Secondly, even if it it back,
<input type='file' will have difficult to set the value.
So, I insert the image directly into the database by another php program add_image.php
http://pastebin.com/jnWuRtdn
But the other part of the form are uploaded separately.
The insertion of the image need to wait till the other part of the form inserted.
...............
so....I got this problem......
Perhaps I did something stupid.
The code was part of OSCommerce, which you might know.
Let me post them
http://pastebin.com/uGddv7wZ
This is the categories.php which administrator need to fill the form and put the products to the shop.
However, I want to built a book store which need at least 100000 products, cannot put by hand.
Therefore I wrote a program the administrator only need to enter ISBN (products number) and price.
The program will get other information (title, author...etc) from other libraries, and the products image.
The problem is products information is text while image is jpg file.
They are handled differently.
I used javascript AJAX call to server to send_one_isbn.php
http://pastebin.com/afB49Zya
This program copy the image and other information.
The "other information" is transmitted back the fill out the form, but image cannot.
Firstly, I don't know how to transmit image file back. Secondly, even if it it back,
<input type='file' will have difficult to set the value.
So, I insert the image directly into the database by another php program add_image.php
http://pastebin.com/jnWuRtdn
But the other part of the form are uploaded separately.
The insertion of the image need to wait till the other part of the form inserted.
...............
so....I got this problem......
Re: event after form submit completion?
Don't do it all in JavaScript. Feel free to write some PHP code to do work.
You can "forge" form information pretty easily with code like
There are a couple potential problems though: functions like is_uploaded_file() require files that were actually just now uploaded, and exit; and die; will completely stop everything.
You can "forge" form information pretty easily with code like
Code: Select all
<?php
// set up fake form values
$_POST["field1"] = "value";
$_POST["field2"] = "value";
ob_start(); // start output buffering so output isn't sent to the browser
include "original_file.php";
ob_end_clean(); // discard everything