why function and if statement don't work on php - 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.

Thursday, March 3, 2022

why function and if statement don't work on php

I have a PHP project and I need to put the birth date so I put it in function this function submit doesn't work with the if statement in the PHP file what I can do with it?


<body>
<?php


function submitt() {
    echo "<h3>your age is: $age  years old </h3>" ; 
    if(isset($_POST['submit'])) {
        submitt();
?>
<form method='POST'>
<h1>Please input your name and birthdate:</h1>
<h3>first name:</h3>
 <input type="text" name="name">
 <h3>second name:</h3>
 <input type="text" name="secName" >
 <h3>your birth date:</h3>
 <input type="text" name="birth" >
 <input type="submit" name="submit" value="Submit " /> 
 </form>
<?php
$name = $_POST['name'];
$secName=$_POST['secName'];
$now_date= date("Y");
$birth=$_POST['birth'];
$age=$now_date-$birth;
echo "<h3> Hello $name $secName </h3>";
?>


source https://stackoverflow.com/questions/71326971/why-function-and-if-statement-dont-work-on-php

No comments:

Post a Comment