Hello,

I have a newoffer php page wich has a form for inserting new data in a mysql database. When the page newoffer.php is opened, a new record will insert with the values NULL. When the form is completed, the record will update with the new information. But if the user will not complete the form fields, how can I remove that new record?

Thank you,
Alex.

Member Avatar

diafol

Why are you creating a NULL record? Doesn't make much sense to me. Just do an INSERT on form completion, then you don't have to do anything.

If you really MUST do this, add a timestamp to the page opening process -> DB. You can use a cron job for 'garbage collection', i.e. delete all NULL records with a timestamp greater than say 4 hours (or whatever).

Use cron job to run a php script that contains the mysql query (delete). BUT, as I mention, this shouldn't really be req'd.

Why are you creating a NULL record? Doesn't make much sense to me. Just do an INSERT on form completion, then you don't have to do anything.

If you really MUST do this, add a timestamp to the page opening process -> DB. You can use a cron job for 'garbage collection', i.e. delete all NULL records with a timestamp greater than say 4 hours (or whatever).

Use cron job to run a php script that contains the mysql query (delete). BUT, as I mention, this shouldn't really be req'd.

Thank you for your answer. I have a sliding-form (tabbed form) for multiple fields. On the final tab, the user will save the images for the new offer (this is done by creating a new folder with the offer name, that will contain the images. This process is made by ajax, javascript and php upload). So, when the user will submit the form, how can i pass the files path, so i can inset them into the database? Should i show you the codes?

Thank's again for the support,
Alex

Member Avatar

diafol

you can keep intermediate data in session variables.

you can keep intermediate data in session variables.

Thank you a lot for the support. I didn't think about the sessions.

Thank you again,
Alex