php Form en pasos (autoguardado después del paso 2)

I'm doing a project and i'm stuck, Hoping someone can help me with this part of my project please :)

In trying to create a simple classifieds section on my website, I had a form for various information which worked fine, then trying to add images to the database i fell into a problem as the listing wasn't created so the images wouldn't tie in. So i decided to do a form with 4 steps... Step 1, choose category, step 2, fill in description, step 3, add photo's, step 4, View listing and confirm it.

Please could someone help me as i'm stuck. What i would like is... Step one. Choose category Step two. Fill in title and description (Then on clicking to step three it will save the data from steps one and two to mysql database. This is where i'm stuck) Step three. Add pictures Step four. Review listing and confirm it. (Will activate in db)

The steps i downloaded from code canyon as i thought this would be an easier and user friendly way.. :) I look forward to your replies and hope i've given enough information:)


preguntado el 09 de marzo de 12 a las 15:03

Been looking at ajax to auto save the form on step two but unable to find what i'm looking for, I'm still new to php so trying to find posts that i can understand the code :) -

lo siento, que código have you done so far? -

And something i've just thought of with you saying that is maybe instead of trying to incorperate someone else code for the steps i should of really learnt how to do the steps myself... -

at the minute it's mainly php and the code i got from codecanyon.. Sorry i think i've done this completely wrong.. blew my mind trying to get it to work not thinking straight.. I believe now i need to go back start it again but learn the steps myself.. that way i should be able to do it :) -

2 Respuestas

You can do either using AJAX or php sessions.

Here is the AJAX way

function autosave() {

new Ajax.Request('autosave.php', 
    method: 'post',
    parameters: {id: $('id').value, save_text: $('myInput').value},


Now call this function with some Interval.

Other way is you need to place you code in php session and you need to habdle it like - every action you need to save your session data, sameway you need to load if you do back and forward.

Provide more details about php version, some forms, fields and database, I will edit my answer

respondido 09 mar '12, 18:03

Thank you for replying Patrick, I am going to start this again as i feel i've done it wrong or gone about it the wrong way by trying to impliment someone elses code. However in your answer and that of Crashspeeder AJAX is the way i should go so Thank you for your time in replying and hopefully i will be able to sort this out by starting the form afresh :D - Steve

Since you're new to PHP I'll give you an idea of what to look for. If your page doesn't use AJAX then validate the post data at each submission. If the post data is valid then save it into the session (use the $ _SESIÓN superglobal) and save it to the database at whichever step you need and wipe out the data you just placed in the session.

Alternatively you can use AJAX and just submit the form when the required steps are completed.

Since you didn't provide any code I won't either, but I figure a nudge in the right direction wouldn't hurt. Come back and post another question when you have some code if you get stuck.

respondido 09 mar '12, 16:03

Hi Crashspeeder... Thank you for your reply... AJAX to submit the form when i require it sounds just what i would like to happen. This is what i have so far.... I need to start this again as i used some code from codecanyon on steps and hoped it would save time by implimenting it into my site.. this has proven me wrong as i should have just learnt how to do this myself :) The right direction for me though is what you say :) Thank you! :) - Steve

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.