'PHP get Value from another file

I have two files

Folder1/addmember.php

Folder2/config.php

now I'm trying to get the values of the radio from file 1

addmember.php

<div class="col">
        <label><?=$lang['newmember']['gender']?>:</label>
        <label class="pt-inline"><input type="radio" name="gender" value="1" /> female</label>
        <label class="pt-inline"><input type="radio" name="gender" value="2" /> male</label>
</div>
  <button type="submit" class="btn btn-primary"><?=$lang['submit']?></button>*

config.php

*include '../Folder1/addmember.php';
        
$answer = $_POST['gender'];  
if ($answer == "1") {          
      
}
else {
    
}*   
php


Solution 1:[1]

You can use a form and point to the config.php, to get that value. For example

<form action="config.php" method="post">
Male: <input type="radio" name="gender"><br>
<input type="submit">
</form>

and in config.php you can get the value from $_POST["gender"]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel