I'm getting error Call to undefined function

theweebokid

Hi I'm new to php and testing some of the codes I'm getting an error of undefined function

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
	<input type="text" placeholder="type your full name" name="fullname">
	<input type="submit" name="submit" value="submit">
</form>

<?php
	$getName = "" ;
	if ($_SERVER["REQUEST_METHOD"] == "POST") {
		$getName = "hello ".test_input($_POST['fullname']);  //Fatal error: Call to undefined function test_input() in C:\xampp\htdocs\ctPHP.php on line 15
	  
	 function test_input($data) {
		  $data = trim($data);
		  $data = stripslashes($data);
		  $data = htmlspecialchars($data);
		  return $data;
	 }
	} 
	echo $getName;
?>

</body>
</html>

I was wondering how to solve this problem , I want to echo out the typed name in the text field , how to solve this one thanks

RJParikh

Just you need to echo after function created.

First create function test_input() then use it after declaration/defination.

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <input type="text" placeholder="type your full name" name="fullname">
    <input type="submit" name="submit" value="submit">
</form>

<?php
    $getName = "" ;
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
         function test_input($data) {
          $data = trim($data);
          $data = stripslashes($data);
          $data = htmlspecialchars($data);
          return $data;
     }
        $getName = "hello ".test_input($_POST['fullname']);  //Fatal error: Call to undefined function test_input() in C:\xampp\htdocs\ctPHP.php on line 15


    } 
    echo $getName;
?>

</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I'm getting a call function error in vba?

I'm attempting to call a function from the context in the componentDidMount function but i'm getting a Cannot read property of undefined error

I keep getting a “Call to undefined function..” error displaying

why i m getting [Error] no matching function for call to 'car::car()'

why I am getting this error "undefined is not a function "

How can I call a module function inside Enum.map without getting an "Undefined reference" error?

Why am I getting an "undefined function" error for a function I wrote?

getting "undefined is not a function" error

I keep getting undefined after async call in another function

I'm getting a 422 error for a function that works

I'm getting a operator undefined error when I use ||

Getting a C error that I have an undefined reference to function, but the function is defined

Getting error on function call

I'm Getting no-unsafe-call and no-unsafe-assignment eslint error on imported function even though function is typed

I'm getting an undefined error in my project made with React

No Idea Why I'm getting std::__1 Undefined Symbols Error

I keep getting "undefined" as an error, function not returning anything

I have no idea why im getting a "undefined is not a function" error

Traceback (most recent call last): I'm getting this error

javascript getting function undefined error

Getting error TypeError: undefined is not a function

While running laravel phpunit testcase , i'm getting an error "Call to a member function connection() on null" in Model.php line 1249

I'm new to PHP and I don't understand why I'm getting this undefined variable error

Uncaught Error: Call to undefined function

phpMyAdmin error call to undefined function

Fatal error: Call to undefined function

Getting Error no matching function for call to ' '

Why am I getting an 'undefined' when I try to call my function?

Getting an Async error when I'm not using an Async function?