Jump to content

Sending form reults after a time laps


Recommended Posts

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?

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();

?>
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.