# Pass a variable to another page - PHP

**URL:** <https://forum.kirupa.com/t/pass-a-variable-to-another-page-php/44960>\
**Category:** Uncategorized\
**Created:** [March 9, 2004, 5:34pm UTC](https://forum.kirupa.com/t/pass-a-variable-to-another-page-php/44960 "2004-03-09T17:34:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [March 9, 2004, 5:34pm UTC](https://forum.kirupa.com/t/pass-a-variable-to-another-page-php/44960/1 "2004-03-09T17:34:44Z")

</div>

I have 2 PHP files:

send\_data.php = has a form, and in the PHP section of the page I declared two variables that are used in the script. when user clicks SUBMIT it takes the user and the info INSIDE the form to receive\_data.php

received\_data.php = received the information that was submitted in the form inside send\_data.php, but cannot use the variables that weren’t declared in the form.

How can I declare variables in a file and then use the variables in another file. (The variables are not declared in the form)???

SEND\_DATA.PHP

\<?php  
$edit\_table=$\_POST[‘edit\_table’];

if ($edit\_table == super)  
{  
echo(“EDITING MESSAGE”);  
$ID = ‘11’; \<\<\<\<\<\< THIS IS THE VARIABLE I WANT TO USE IN RECEIVE\_DATA.PHP

$sql\_body = “SELECT body FROM $edit\_table WHERE id = $ID”;  
$result\_body = mysql\_db\_query(‘content’, $sql\_body);  
$row\_body = mysql\_fetch\_array($result\_body);  
$body = $row\_body[“body”];  
?\>

\<form action=“receive\_data.php” method=“post” name=“edit\_message”\>  
\<p\>Edit:\</p\>  
\<textarea name=“content” cols=“70” rows=“20” wrap\>  
\<?php echo $row\_body[“body”]; ?\>  
\</textarea\>

\<p\>  
\<input type=“submit” name=“submitContent” value=“SUBMIT” /\>  
\</p\>  
\</form\>
