error to displaying name with messages in 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.

Wednesday, September 28, 2022

error to displaying name with messages in php

**i am writing a script for my project, i am facing a little bit error.

this code display only 'eligible messages', i want to showing user name also in output. pls solved it.**

**<?php
    $name = $_POST['name'];
    $dateOfBirth1 = $_POST['dob'];
    $today1 = date("Y-m-d");
    $diff1 = date_diff(date_create($dateOfBirth1), date_create($today1),);
    if($diff1->format('%y')>= 21){
        header('Content-Type: application/json');
        echo ($name);   
        echo json_encode(array('flag'=>1, 'msg'=> ' You are eligible. Your Age is: '.$diff1->format('%y').' Years, '.$diff1->format('%m').' months ,'.$diff1->format('%d').' days'));
        exit;
    }else{
        header('Content-Type: application/json');
        echo ($name);
        echo json_encode(array('flag'=>1, 'msg'=>' You are not eligible. Your Age is: '.$diff1->format('%y').' Years, '.$diff1->format('%m').' months ,'.$diff1->format('%d').' days'));
        exit;
    }
?>**


source https://stackoverflow.com/questions/73872114/error-to-displaying-name-with-messages-in-php

No comments:

Post a Comment