-1

HELP! For this specific HTML code, I would want to send a message to an email address at a specific date and time. The date is 1/1/2013 and the time is 2:12am. I would like to input a message and send that message to an email at the given date and time. How would I do this according to the code below? Either using php or html?

<html>
    <head>
        <title> Lab </title>
    </head>
    <body>
        <div id="login">
            <form method="post" action"#">
                <p>
                    E-mail
                    <input type="email" name="email">
                </p>
                <p>
                    Message
                    <br>
                    <textarea cols="50" rows="4" name="message"> </textarea>
                </p>
                <p>
                    Date: Month
                    <select name="month">
                        <option value="01"> 1 </option>
                    </select>

                    Day
                    <select name="day">
                        <option value="01"> 1 </option>

                    </select>

                    Year
                    <select name="year">
                        <option value="2013"> 2013 </option>
                    </select>

                    Hour
                    <select name="hour">
                        <option value="02"> 02 </option>
                    </select>

                    Minute
                    <select name="minute">

                        <option value="12"> 12 </option>

                    </select>
                </p>

                <input type="submit" name="submit" value="Submit">
            </form>
        </div>
    </body>
</html>
Mathlight
  • 5,847
  • 15
  • 58
  • 103
Matthew Luong
  • 21
  • 1
  • 4

2 Answers2

2

You've got to use PHP, with some mysqli and an cronjob.

First you save the "message" ( from the HTML form ) in the database. Make sure you save the uid of that entry in PHP

Second you create an cronjob with PHP. more about that HERE. Make the cron job so that it will be executed when needed and that the UID is in the url to ( as an GET variable )

third, you need an page where the cron job is heading to. Make sure that an GET variable with the UID is passed to the page.

Get the info out of the DB and mail the message.

Community
  • 1
  • 1
Mathlight
  • 5,847
  • 15
  • 58
  • 103
-1

First thing you need to do is format the email, set the action value to some php page (for example process.php

You can access the variables from the $_POST array, I would then put it into a database with fields for: to,message,subject,and the time that its supposed to go out (format the date into a timestamp using the date() function http://www.php.net/manual/en/function.date.php

http://www.w3schools.com/php/php_mysql_connect.asp - this is a good tutorial for mysql

Then create a cron job from your control panel that runs a php script with the following sudo code every minute(if you really want to get ocd about it you can write a script that creates cron jobs everytime a new email is added)

1.Connect to database

2.Find anything with a timestamp before the current time (calculated with the time() function)

3.Send out the email with the php email function (or a library )

  1. Delete the row from the database
Jake
  • 338
  • 1
  • 5
  • 1. The `mysql_*` functions in PHP are deprecated. 2. [w3fools.com](http://www.w3fools.com/). –  Aug 07 '13 at 01:59