Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all you can probably deal with your dates in code rather then send them from client. And most importantly you don't want to change <code>signup_date</code> on every UPDATE. So you need to tweak your table schema a bit:</p> <pre><code>CREATE TABLE `expirydate_table` ( `id` INT NOT NULL AUTO_INCREMENT , `firstname` VARCHAR( 45 ) NOT NULL , `lastname` VARCHAR( 45 ) NOT NULL , `email` VARCHAR( 45 ) NOT NULL , `password` VARCHAR( 12 ) NOT NULL , `signup_date` DATETIME NOT NULL, `expiry_date` DATETIME NOT NULL, PRIMARY KEY (`id`) , UNIQUE (`email`) ) </code></pre> <p>That being said you can get rid of <code>signup_up</code> and <code>expiry_date</code> fields in your form.</p> <p>Then you need to create an action php script that will deal with submitted values. It may look something like this:</p> <pre><code>&lt;?php //make sure that everything has been submitted if (isset($_POST['firstname']) &amp;&amp; isset($_POST['lastname']) &amp;&amp; isset($_POST['email']) &amp;&amp; isset($_POST['password'])) { //do your cleanup and checks here $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $email = trim($_POST['email']); $password = $_POST['password']; //construct an INSERT statement $qry = 'INSERT INTO `expirydate_table` (`firstname` , `lastname` , `email` , `password` , `signup_date` , `expiry_date` ) VALUES ('; $qry .= '"' . $firstname . '", '; $qry .= '"' . $lastname . '", '; $qry .= '"' . $email . '", '; $qry .= '"' . $password . '", '; $qry .= 'NOW(), '; $qry .= 'DATE_ADD(NOW(), INTERVAL 30 DAY))'; //open connection to db $db = new mysqli('db_host', 'db_user', 'db_pwd', 'db_name'); //execute your INSERT statement if ($db-&gt;query($qry) == TRUE) { if ($db-&gt;insert_id) { $id = $db-&gt;insert_id; } } else { //add your error handling here } //render your page, use $id if you need to } ?&gt; </code></pre> <p>That's definitely not everything you need to do it right. You better, at least:</p> <ul> <li>do input validation on the client </li> <li>do proper check, validate and sanitize user input on server side </li> <li>use prepared statements </li> <li>implement proper error handling in place</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload