If you include multiple PHP scripts in a script are those variables accessible by the script? For example, I have one file called post.php. Within this I have...
include(email.php);
include(input.php);
Are the variables within each of these scripts self contained even if they are "included" on the same page? If they are, how can I access them within each of the scripts. I ask because I can't call variables in "post.php" that I have defined in the other scripts. Thanks
EDIT WITH COMPLETE CODE
Here is my first page where I gather data from my user:
<form action="postinput.php" method="post">
<input type="text" placeholder="Name"name="Name"><br>
<input type="text" placeholder="Email"name="Email"><br>
<input type="text" placeholder="Title"name="Title"><br>
<textarea placeholder="Post" rows="4" cols="22" placeholder="Post"name="Post"></textarea>
</form>
Here is the second page where I take this data and use fopen to create a random "post" page out of the supplied data:
$getname = $_POST['Name'];
$getemail = $_POST['Email']; //Here is the email variable I am trying to pass
$gettitle = $_POST['Title'];
$myfile = fopen("$random" . ".php", "w");
$txt = "<?php include('post.php'); \$email = \"$getemail\";?>" //pass email variable and include post.php
fwrite($myfile, $txt);
print("you can see your post here:");
echo ('http://localhost/' . $random . '.php');
Here is post.php. This should include the $email variable I passed above but I cannot even echo the variable. If I pull up the php page that was generated I can see that the variable is declared but I still cannot access it for some reason.
<?php
include('Header.php');
?>
<div id = "center">
<form action="" name="emailform" method="post">
<input type="text" name="name">
<input type="text" name="email">
<input type="text" name="message">
<input type="submit" name="Send" value="Send Email">
</form>
</div>
<?php
echo $email;
if (isset($_POST['Send'])) {
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = '[email protected]';
$email_subject = "You have a reply from better barter";
$email_body = "Message from: $visitor_email \n \n Message:$message";
$to = $email;
$headers = "from:adam\r\n";
mail($to,$email_subject,$email_body,$headers);
} else {
echo 'You have not hit the submit button yet';
}
?>
globalbefore using them. like:global $myvariable;