PHP date Post error keep getting Undefined array key [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Wednesday, June 2, 2021

PHP date Post error keep getting Undefined array key [duplicate]

I've been trying to fetch the date using post to my database but it always gives me "Undefined array key"`tried to srttotime and dateformat but non worked for me and i keep getting the same error

<form method="post" action="W2php.php">
<div>
<div>
<p>If you would like to join our event please fill the form below:</p>
      <label ><input type="name" placeholder="Enter your name here" required autocomplete="on" name="name"></label>
      <label ><input type="email" placeholder="Enter your Email" required autocomplete="on" name="email"></label>
      <label ><input type="tel" placeholder="07XXXXXXXX" pattern="\{d10}" required autocomplete="on" name="tel"></label>
</div>
      
     <div>
      <label><input type="date" placeholder="Choose your age" required autocomplete="on" name="aget"></label>
      </div>
      

 </form>`

this is a snippt from the html code and this is my php code

<?php

session_start();
include("connection.php");

if(isset ($_POST['submit']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $tel = $_POST['tel'];
    echo date_format($_POST['aget'],'Y-m-d');
        
    
$querry = "INSERT INTO users (name,email,phone,age,gender) VALUES('$name','$email','$tel')";
mysqli_query($con,$querry);
}

?>


<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
body {
  background-color: black;
  text-align: center;
  color: white;
  font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>

<h1>Thats AWESOME</h1>
<p>Soon you will start learning</p>
<p>Here is your information</p>
</body>
</html>


source https://stackoverflow.com/questions/67797117/php-date-post-error-keep-getting-undefined-array-key

No comments:

Post a Comment