how to take the value from another .php file help me fix this:
<html>
<head>
</head>
<body>
<form name='answer' action="file2.php" method="post">
<input type="text" name="what">
<input type="submit" value="Login">
</form>
<div><?php echo $answer; ?></div>
</body>
</html>
And the code of file2.php file is as below:
<?php
if ($_POST['what']==animal){
$answer="dog";
}else{
$answer= "not animal";
}
I would like to know how can I get the value of the variable $answer with button, then what should I put at the line :
Use require_once()
to include file2.php in your php file, then in your file you can access the variables in file2.php.
require_once("path of file2.php");
echo $answer;
只需使用要求
<?php require 'file2.php'; ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.