For example, i have a data input program And I want to delete my data automatically after 1 day of this data I input. how I do that?
Someone can explain in code?
Create.php these values are sent to the server
<form action="" method="post" enctype="multipart/form-data">
<input type="text" name="name_portofolio">
<textarea name="info_portofolio"></textarea>
<input type="file" accept="image/*" name="picture_portofolio">
<button type="submit" name="submit">Save</button>
</form>
function-add.php
<?php
function create_data($name_portofolio, $info_portofolio,
$picture_portofolio)
{
global $connect;
$name_portofolio = mysqli_real_escape_string($connect, $name_portofolio);
$info_portofolio = mysqli_real_escape_string($connect, $info_portofolio);
$filePath = "picture/".basename($picture_portofolio["name"]);
move_uploaded_file($picture_portofolio["tmp_name"], $filePath);
$query = "INSERT INTO portofolio
(name_portofolio, info_portofolio, picture_portofolio)
VALUES ('$name_portofolio', '$info_portofolio', '$filePath')";
if(mysqli_query($connect, $query))
{
return true;
}else{
return false;
}
} // create_data
db.php
<?php
$host = "127.0.0.1";
$user = "root";
$password = "";
$db = "wherco";
// create connection
$connect = new mysqli($host, $user, $password, $db);
// check connection
if($connect->connect_error) {
die("connection failed : " . $connect->connect_error);
} else {
// echo "Successfully Connected";
}
?>
thanks .
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…