1

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:)

Thank you!

4
  • 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 :) Commented Mar 9, 2012 at 15:42
  • Sorry, what code have you done so far? Commented Mar 9, 2012 at 15:43
  • 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... Commented Mar 9, 2012 at 15:44
  • 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 :) Commented Mar 9, 2012 at 15:48

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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
0

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 $_SESSION 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.

1 Comment

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! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.