473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

variable cannot be passed to multiple pages.

32 New Member
i have designed a login page like this:

[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Electric al Engineering Dept IITK</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {font-size: 14px}
.style3 {font-size: 18px}
.style4 {font-size: 24px}
.style5 {font-size: 36px}
-->
</style>
</head>

<body bgcolor="#99CCF F">
<form name="form1" method="post" action="../myphp/validate1.php">
<div align="center">
<p> <span class="style1">
</span></p>
<pre><span class="style1"> <span class="style2"> <span class="style3"> <span class="style4"> <span class="style5"> <label><u>Elect rical Engineering Department IIT-KANPUR</u></label></span></span></span></span></span></pre>
<p>&nbsp;</p>
<p><span class="style1"> </span> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="38%" border="0">
<tr>
<th scope="row"><di v align="left">
<label>User Name</label>
&nbsp;</div></th>
<td><input name="username" type="text" size="35" maxlength="35"> </td>
</tr>
<tr>
<th height="29" scope="row"><di v align="left">Pa ssword</div></th>
<td><input name="password" type="password" size="35" maxlength="35"> </td>
</tr>
</table>
&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;
<p>&nbsp;</p>
<table width="2%" border="0" align="center">
<tr>
<th scope="row"><in put type="submit" name="Submit" value="Login"></th>
<td><input type="submit" name="Submit2" value="Cancel"> </td>
</tr>
</table>
<p>&nbsp;</p>

<label><u><stro ng></strong></u></label>
</p>
</div>
</form>
</body>
</html>[/HTML]

this page is calling validate.php which is :

[PHP]<?php
session_start() ;
$passwords = array("ajohari" =>"anurag",
"knaveen" =>"naveen",
"pkk" =>"kalra",
"anu" =>"anu");
if ($password == $passwords[$username]){
$_SESSION['user']=$username?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Faculy Information of E.E Depatment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<frameset rows="144,*" cols="*" frameborder="NO " border="0" framespacing="0 ">
<frame src="frame1.php " name="topFrame" scrolling="NO" noresize >
<frameset rows="*" cols="257,*" framespacing="0 " frameborder="NO " border="0">
<frame src="frame2.php " name="leftFrame " scrolling="NO" noresize>
<frame src="frame3.php " name="mainFrame ">
</frameset>
</frameset>
</html>
<?
exit();
}else{
echo "<H2>Invali d user name or password: access denied.</H2>";
include("../myphp/eeiitk.php");
}
?>[/PHP]

after validating frame3.php page is called which is:

[PHP] <?php
session_start() ;
$connection = pg_connect("hos t=localhost dbname=personal user=postgres") ;
if (!$connection) {
print("Connecti on Failed.");
exit;
}
$username1=$_SE SSION['user'];

$myresult = pg_exec($connec tion, "SELECT * FROM personal where username='usern ame1'");

for ($lt = 0; $lt < pg_numrows($myr esult); $lt++) {
$name = pg_result($myre sult, $lt, 0);
$designation = pg_result($myre sult, $lt, 1);
$department = pg_result($myre sult, $lt, 2);
$telephonework = pg_result($myre sult, $lt, 3);
$telephoneres = pg_result($myre sult, $lt, 4);
$fax = pg_result($myre sult, $lt, 5);
$email = pg_result($myre sult, $lt, 6);
$address = pg_result($myre sult, $lt, 7);
$areaofinterest = pg_result($myre sult, $lt, 8);
$username= pg_result($myre sult, $lt, 9);
$image= pg_result($myre sult, $lt, 10);
}
?>

<body bgcolor="#FFCC9 9">
<form name="form1" method="post" action="pupdate .php">
<p>&nbsp;</p>
<table width="575" border="0" cellpadding="1" cellspacing="1" >
<tr>
<th width="148" scope="row"><di v align="left">
<label>IMAGE</label>
</div></th>
<td width="361">
<div align="center">
<input name="image" type="image" src="../naveen_iitk/photos/pkkalra.jpg" width="320" height="240" border="0">
</div>
</td>
<td width="66">
<div align="center">
<input type="submit" name="Submit" value="Upload">
</div>
</td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>USERNAME </label>
</div></th>
<td>
<div align="left">
<input name="username" type="text" size="60" maxlength="50" readonly="" value="<? echo "$username" ; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>NAME</label>
</div></th>
<td>
<div align="left">
<input name="name" type="text" size="60" maxlength="50" value="<? echo "$name"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row">
<div align="left">
<label>DESIGNAT ION</label>
</div></th><td><div align="left">
<input name="designati on" type="text" size="60" maxlength="50" value="<? echo "$designati on"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>DEPARTME NT</label>
</div></th>
<td>
<div align="left">
<input name="departmen t" type="text" size="60" maxlength="50" value="<? echo "$departmen t"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><di v align="left"><l abel>TELEPHONE( Work)</label>
</label>
</div></th><td><div align="left">
<input name="telephone work" type="text" size="60" maxlength="50" value="<? echo "$telephonework "; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><di v align="left"><l abel>TELEPHONE (Res)</label>
</label>
</div></th><td><div align="left">
<input name="telephone res" type="text" size="60" maxlength="50" value="<? echo "$telephoneres" ; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>FAXNO. </label>
</div></th>
<td><div align="left">
<input name="fax" type="text" size="60" maxlength="50" value="<? echo "$fax"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>EMAIL</label>
</div></th>
<td><div align="left">
<input name="email" type="text" size="60" maxlength="50" value="<? echo "$email"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>ADDRES S</label>
</div></th>
<td>
<div align="left">
<textarea name="address" cols="46" rows="5"><? echo "$address"; ?></textarea>
</div>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<th height="150" scope="row">
<div align="left">
<label>AREA OF INTEREST</label>
&nbsp;</div></th>
<td><div align="left">
<textarea name="areaofint erest" cols="46" rows="8"><? echo "$areaofinteres t";?></textarea>
</div>
</td>
<td>&nbsp;</td>
</tr>
</table>
<div align="center">
<input type="submit" name="submit" value="Update">
<input type="reset" name="reset" value="Clear It">
</label>
</label>
</div>
</form>
</body>
</html>[/PHP]


But the session_start is not working. The data from the table is not fetched.
Can u tell me that where I m going wrong.
Feb 6 '07 #1
3 1659
ronverdonk
4,258 Recognized Expert Specialist
Oh yes, these variables can, and indeed are, passed to the script. But you have not assigned the passed POSTed values for username and password the the appropriate variables.

Script validate.php must begin as follows:

[php]<?php
session_start() ;
$username = trim(strip_tags ($_POST['username']));
$password = trim(strip_tags ($_POST['password']));
// ... etc ...[/php]
Ronald :cool:
Feb 6 '07 #2
anuragpj
32 New Member
It is not working.
How can I pass tee variable in different scripts?
Please help!
Feb 7 '07 #3
ronverdonk
4,258 Recognized Expert Specialist
I am sure it works but somehow you don't handle the POSTed values not correctly. Show the code.

Ronald :cool:
Feb 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1839
by: sentinel | last post by:
Hi All, Advice gratefully needed....... I am trying to present the same content on multiple sites, but allowing the style and formatting to be changed via an external CSS style sheet. The problem is the client site pulls of the content from my main site into an IFRAME on their site. Because the content of the IFRAME on the
8
2209
by: 2L | last post by:
Trying to write some code and this is just shitting me now! Bit of form validation stuff.... Variable is declared as follows..... --snip-- <script language="JavaScript"> <!---
7
15914
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script type="text/javascript"> window.location = "http://www.someserver.com/somePage.html"; </script>
0
2518
by: olafmol | last post by:
Hello, i have a problem using a .NET WSDL Webservice from PHP. Using both the NuSOAP lib for PHP4, and the build-in SOAP lib for PHP5 it seems that the SOAP client cannot pass a variable amount of complex datatypes to the WSDL webservice. This is the request-structure we've been using: <EzCreateAuctionArray xmlns=http://www.blabla.com>
41
10658
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query = String.Format("SELECT * FROM dbo.documents WHERE ") & query End Sub
1
1782
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open the second page using Window.Open with the values being passed to the second page by a global variable created in a Module added to the project, by the use of an Application variable and by the use of a session variable. In the page load of the...
2
1497
by: bcshaw | last post by:
Hey all I have a vb.net/asp.net dynamic website connected to an access database using a oledb connection. I use a datareader to retrieve the results of a query and iterate through the results using the read() method. The page in question is a string matching search page (its a photo site and the photos have associated tags) that may return multiple results. I wish to display the first picture match and its details and then have a button that...
0
2037
by: zman77 | last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine Hi. This is my first post, though I've "lurked" for a while because I find these forums very helpful. Ok my problem is the following. I have a class that contains a "MakeByteArray" function. I have many objects of that class. Inside that function, I have a private variable, that is NOT static. It seems that when I put all these objects in...
3
4758
by: hon123456 | last post by:
Dear all, I have a session variable session("loginid) which can be passed from A.asp to B.asp. Then In B.asp I have a hyperlink to C.asp e.g. < A href..C.asp>. The session variable cannot be passed to C.asp. The session variable is empty. What can I do to debug this problem? Thanks
9
1643
by: Animesh K | last post by:
Hello All: I want to have some re-usable variables, which can be used inside (as well as outside) objects. The use of GLOBALS array is one option, but then I will have to keep track of "reserved variable names" elsewhere. Another option is to declare a $FORALL array in an abstract class and initialize it. And then define every object as an extension of this abstract class.
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.