How to send a value stored in a variable from one page to another page in php?
Posted by: Chaitanya (---.160.207.20.ill-bgl.static.vsnl.net.in)
Date: September 19, 2007 06:33AM

Sir,

I am working on a project on website development in my company. I got struck at some point in my code. Hope you will help me out in resolving the problem.

Normally in this, whenever a user registers himself with our site in our signup page, his details must first go to pending table of the database. Whenever the administrator approves his request, the user details must be moved from pending table to the Members table.

I have developed the code for both the pages, only iam not able to send the employee ID value stored in the Pending page to the Approve page, where the admin approves.

I am providing you with my codes below :

Pending.php
-----------------

<html>
<head>
<title> Pending Table </title>
</head>

<body>

<u><h2> Pending Records to be approved by the Admin : </h2></u>
<br>


<?php

$dbhost='localhost';
$dbuser='root';
$dbpass='';

$conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error, Cannot connect to mysql');

$dbname='stroogle8';
mysql_select_db($dbname) or die('Error, cannot connect to stroogle8 database');

$Firstname=$_POST['Firstname'];
$Lastname=$_POST['Lastname'];
$EmpID=$_POST['EmpID'];
$EmailID=$_POST['EmailID'];
$Password=$_POST['Password'];

$query = "SELECT * FROM Pending";
$result = mysql_query($query) or die('Error, cannot retrieve the data from the database');


echo "<table border='1'>
<tr>
<th>Employee ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email ID</th>
<th>Password</th>
<th>Approve</th>
<th>Reject</th>
</tr>";


while($row = mysql_fetch_array($result))
{
$val=$row['EmpID'];
echo $val; echo "<br>";
// echo "<form name='form2' action='Approve.php' method='post'><input type='hidden' id='Emp_val' name='EmpID_val' value='$val'>";
echo "<tr>";
echo "<td>" . $row['EmpID'] . "</td>";
echo "<td>" . $row['Firstname'] . "</td>";
echo "<td>" . $row['Lastname'] . "</td>";
echo "<td>" . $row['EmailID'] . "</td>";
echo "<td>" . $row['Password'] . "</td>";
?>
<td><form name="form2" action="Approve.php" method="post"> <input type="hidden" id="val" name="val" value="<?php $val ?>"<input type="submit" value="Approve"></form></td>";
<td><form name="form3" action="Reject.php" method='post'> <input type="hidden" id="val1" name="val1" value="<?php $val ?>" <input type="submit" value='Reject'></form></td>";
<?php
echo "</tr>";

}
echo "</table>";
echo document.form2.xyz.value;
//echo $val;

?>


-------------

I want to get the value (EmpID value), and send it to the Approve.php page, so that i can perform the desired action.

My Approve.php page looks like this :

Approve.php
------------------

<?php

echo "Approve page";

$dbhost='localhost';
$dbuser='root';
$dbpass='';

$conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error, Cannot connect to mysql');

$dbname='stroogle8';
mysql_select_db($dbname) or die('Error, cannot connect to stroogle8 database');

echo "<br>";

$EmpID=$_POST['val'];;
echo $EmpID;

$query = "INSERT INTO Members SELECT * FROM Pending WHERE EmpID='$EmpID'";
$result = mysql_query($query);

echo "<br>";

if($result)
echo "Successfully copied from Pending to Members table";

mysql_close($conn);

?>
----------------

Please tell me how can i retrieve the EmpID value in a PendingTable , store it in a variable and send the same value to Approve.php page for necessary action.

Consider for example, pending table looks like below. On the right corner of every row, there will be APPROVE & REJECT buttons. The admin when clicks APPROVE, the record must go to the Members table. Also simultaneously a confirmation link must be sent to the user saying that "Admin has approved your request. Now you can login using your Emp ID and Password".


Employee ID Firstname Lastname Email ID Password
5347 rahul varshaneey rahul@tataelxsi.co.in rahul123

9676 arjun patel arjun@tataelxsi.co.in arjun123



Please reply to my query to my mail ID : chaitanya_b2w@zapak.com

I appreciate your immediate response.

Thank you,

chaitanya

Options: ReplyQuote
Re: How to send a value stored in a variable from one page to another page in ph
Posted by: CyberSpatium (---.hsd1.or.comcast.net)
Date: September 26, 2007 10:34PM

use php's sessions. this is built into php so there is not file to edit, and nothing to configure to get it to work.

[us.php.net]


CyberSpatium
----------------------
WAMP English Forum Admin

I have WAMP5 working with (for development use only):
Windows Vista Ultimate x64 (64 bit)
Kaspersky Internet Security Suite 7.0.x
Spyware Terminater 2.x
CounterSpy 2.5.x


Need help? Check out my WAMP User Manual/Guide here!


Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.


Clarify Loans
Mortgage and Home Loan Advice


LaxGo Web Directory
Powerful human edited web directory of quality, spam-free sites organized via a comprehensive category structure.

Options: ReplyQuote


Sorry, only registered users may post in this forum.