Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-18-2007, 03:30 AM   #1 (permalink)
Chaitanya Kiran
Junior Member
 
Join Date: Sep 2007
Posts: 1
Default How to send a value stored in a variable from one page to another page in php?

Sir,

I am working on a project on website development. 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
Chaitanya Kiran is offline   Reply With Quote
Sponsored Links
Old 10-16-2007, 09:51 AM   #2 (permalink)
wrkjmg
Junior Member
 
Join Date: Oct 2007
Posts: 5
Default Re: How to send a value stored in a variable from one page to another page in php?

Use SESSIONS or use the GET metod:
Approve.php?EmpID=(value).

In aprove.php:
EmpID = $_GET['EmpID']
wrkjmg is offline   Reply With Quote
Old 10-23-2007, 08:59 PM   #3 (permalink)
freemori
Junior Member
 
Join Date: Jul 2006
Posts: 14
Default Re: How to send a value stored in a variable from one page to another page in php?

hi you can add the $val=$row['EmpID']; to form 's action
eg.'<form name="form2" action="Approve.php?var=$val" method="post">'
in aprove.php:
EmpID = $var;
freemori is offline   Reply With Quote
Old 11-27-2007, 11:01 AM   #4 (permalink)
vpsville
Junior Member
 
Join Date: Nov 2007
Posts: 16
Default Re: How to send a value stored in a variable from one page to another page in php?

You really want to use $_SESSION, thats what its for. I suggest you read up on it and use it, its not that hard. It will also give you an idea of how best to structure your site.
__________________
VPSVille
Canada's VPS Host
www.vpsville.ca
vpsville is offline   Reply With Quote
Old 01-11-2008, 04:37 PM   #5 (permalink)
Rohan Shenoy
Junior Member
 
Join Date: Jan 2008
Posts: 2
Default Re: How to send a value stored in a variable from one page to another page in php?

Here is how I understand your situation:
1. You have a website where users can register.
2. After registration, each account needs to be activated. till then it lies in the 'un-activated' table.
3. Activation can be done by the admin.
4, After activation, it should be moved to 'activated' table.

If I have understood it correct, then what I suggest is instead of moving the records between tables:
1. Have a single table for all users whether activated or un-activated.
2. Have a column by the name 'activated' whose default value will be 'no'.
3. When you want to activate the un-active account, simply update the 'activated' column from 'no' to 'yes'.

As simple as that!
Rohan Shenoy is offline   Reply With Quote
Old 02-19-2008, 09:57 AM   #6 (permalink)
SupportFox
Junior Member
 
Join Date: Feb 2008
Location: South England
Posts: 4
Default Re: How to send a value stored in a variable from one page to another page in php?

There are several options.

$_SESSION
$_GET

or use a database.
SupportFox is offline   Reply With Quote
Old 02-22-2008, 06:35 AM   #7 (permalink)
zesiakade
Junior Member
 
Join Date: Feb 2008
Posts: 1
Post !Hello!

Good
site.
zesiakade is offline   Reply With Quote
Old 03-04-2008, 04:53 AM   #8 (permalink)
gayle
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Re: How to send a value stored in a variable from one page to another page in php?

u hv 3 options 1.Session 2.Get 3.My Sql
__________________
Porting and Testing services
gayle is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:49 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums