473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

variable cannot be passed to multiple pages.

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>Electrical 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="#99CCFF">
<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>Electrical 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"><div 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"><div align="left">Password</div></th>
<td><input name="password" type="password" size="35" maxlength="35"></td>
</tr>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;
<p>&nbsp;</p>
<table width="2%" border="0" align="center">
<tr>
<th scope="row"><input type="submit" name="Submit" value="Login"></th>
<td><input type="submit" name="Submit2" value="Cancel"></td>
</tr>
</table>
<p>&nbsp;</p>

<label><u><strong></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>Invalid 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("host=localhost dbname=personal user=postgres");
if (!$connection) {
print("Connection Failed.");
exit;
}
$username1=$_SESSION['user'];

$myresult = pg_exec($connection, "SELECT * FROM personal where username='username1'");

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

<body bgcolor="#FFCC99">
<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"><div 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"><div 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"><div 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>DESIGNATION</label>
</div></th><td><div align="left">
<input name="designation" type="text" size="60" maxlength="50" value="<? echo "$designation"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>DEPARTMENT</label>
</div></th>
<td>
<div align="left">
<input name="department" type="text" size="60" maxlength="50" value="<? echo "$department"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><div align="left"><label>TELEPHONE(Work)</label>
</label>
</div></th><td><div align="left">
<input name="telephonework" type="text" size="60" maxlength="50" value="<? echo "$telephonework"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><div align="left"><label>TELEPHONE (Res)</label>
</label>
</div></th><td><div align="left">
<input name="telephoneres" type="text" size="60" maxlength="50" value="<? echo "$telephoneres"; ?>">
</div></td>
<td>&nbsp;</td>
</tr>
<tr>
<th scope="row"><div 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"><div 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"><div align="left">
<label>ADDRESS</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="areaofinterest" cols="46" rows="8"><? echo "$areaofinterest";?></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 1645
ronverdonk
4,258 Expert 4TB
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
It is not working.
How can I pass tee variable in different scripts?
Please help!
Feb 7 '07 #3
ronverdonk
4,258 Expert 4TB
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
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...
8
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
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...
0
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...
41
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 =...
1
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...
2
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...
0
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....
3
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...
9
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...

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.