EricOnAdventure Posted June 7, 2016 Share Posted June 7, 2016 I have some rather complex forms that output into a mySQL database. Right now all of the results are placed in the database along with html formatting. Yes that means the columns are huge but I can't find a better way to do it right now without spending a few days writing code. I want the results to show up on another page 48 hours after they are created. Any idea how I might do this? Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/ Share on other sites More sharing options...
ginerjm Posted June 7, 2016 Share Posted June 7, 2016 You have some 'complex forms' that are 'written' to a database. So you have a script that takes input values only as per the usual $_GET or $_POST array value and writes them into one column of a table record? You say that your columns are huge but why is that? They simply contain a value, don't they? Where is this HTML that you mention coming from since it didn't come to your script via the GET or POST arrays? Your description implies that you are receiving input that literally represents the html form that the client has just filled in and that you are saving it as is. I don't know how this is done, so perhaps you can add some more specifics to your situation here so that the premise makes more sense. Or perhaps I'm just too old and slow to see it. Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533457 Share on other sites More sharing options...
EricOnAdventure Posted June 7, 2016 Author Share Posted June 7, 2016 Hey Ginerjm, To be more exact my code takes the form data and uses another rather large auto-writing script to write a document. The output file, is html formatted text that is about 500 words long. So the columns are set to 5000 characters just to be safe. While I can have this text display perfectly well on another page instantly, my goal is to have it displayed in 48 hours...because I would rather not have the person who filled out the form know the letter was automatically generated. Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533458 Share on other sites More sharing options...
kicken Posted June 7, 2016 Share Posted June 7, 2016 When you save the data to the database, also include a column set to the current time. Then when you display data, only display data that was added <= NOW() - 48 hours Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533463 Share on other sites More sharing options...
ginerjm Posted June 7, 2016 Share Posted June 7, 2016 So - after 48 hours transpire, who is going to see this new page you send with the form data and where is it going to show up? Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533464 Share on other sites More sharing options...
EricOnAdventure Posted June 7, 2016 Author Share Posted June 7, 2016 So - after 48 hours transpire, who is going to see this new page you send with the form data and where is it going to show up? Well the form is in a member section so only the member. When you save the data to the database, also include a column set to the current time. Then when you display data, only display data that was added <= NOW() - 48 hours I tried this idea but I ran into a wall, any ideas? <?php $submittime = 1; $displaytime = $submittime + 172800; // 2 days if (time() >= $displaytime) {echo 'yes'} echo $submittime; echo $displaytime; echo time(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533465 Share on other sites More sharing options...
Psycho Posted June 7, 2016 Share Posted June 7, 2016 I don't think you read Kicken's response - at least not correctly. In your DATABASE TABLE, you need a field for the time a record is submitted. The field should be a TIMESTAMP field type with a default value of CURRENT_TIMESTAMP. Then, whenever a new record is created, the current timestamp will be populated int he field for that record without having to include any logic in the INSERT query. Then, when you retrieve records you would use that timestamp to determine whether to display the contents or not. You could just query the records that are more than two days old, as Kicken suggests, but I would expect that if a user has submitted a record that the page should let them see that. So, I would query for the record for the user. If none exists, tell them that. If one does exist, check the timestamp. If the timestamp is less than 2 days old, then show a message that their submission is being processed. Else, show the content. 1 Quote Link to comment https://forums.phpfreaks.com/topic/301309-sending-form-reults-after-a-time-laps/#findComment-1533469 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.