Problem in passing variables between PHP pages
Posted: Mon Jul 05, 2010 9:22 am
Hi all....I am new to this forum and php coding. I am designing a website for posting articles where users will be able to post anything and comment to any submitted post. But the problem I am facing is to pass the post id (or any variable) from 1 php file to another. I am using hidden variable concept to pass variabes. Here is the code:
Can you tell me what may be the problem...I am retrieving the variables like this:
Please Help 
Code: Select all
//the variable has to be passed in new.php
[b] <form action="new.php" method="post" enctype="multipart/form-data">[/b]
// $clb[club] is the variable that needs to be passed
[b]<?php $var = $clb[club];
echo "<input type='hidden' id='club' name='club' value='$var' >"; ?>[/b]
// code for taking input from the user
<input type="text" size="50" name="text" id="textfield" />
<select name="what" id="select">
<option selected="selected">act</option>
<option>issue</option>
<option>diss</option>
</select>
<label for="button"></label>
<input name="post" type="submit" id="button" value="post" />
<label for="file"><br />
</label>
<p>Recent posts of club1: </p>
<p>
// I also want $clb[club] to be passed in the file old.php....but even here variables are not passed at all!!!
[b] <?php include("old.php"); ?>[/b]
</p>
</form>
// I have even tried this format...I am passing $var1 in club.php when user clicks the link Friend but same story here
[b]<form action="club.php" method="post" enctype="multipart/form-data">
<?php $var1 = $_POST['club1'];
echo "<input type='hidden' id='club' name='club1' value='$var1' >"; ?>
<a href="club.php">Friend
[/b] </p>
</a>
</form>
Code: Select all
// in new.php
$ret = $_POST['var'];