473,883 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get request parameter from one php page to another page

3 New Member
hello everyone...
myself Nawaz from Mangalore...

I've created a web page using jsp.. now i want to convert it to php.... so please help me out... i want to know how to pass parameter to another page and get request from the previous page... u can give with example.... like i want to create a login page... now user will enter his/her id and password... i want to check whether its a valid one or not.. if its a valid one then it should go to another page.. else stay in current page... so please help me in solving this problem...

Nawaz
Sep 26 '06 #1
4 39361
skim
9 New Member
Using "SESSIONS"
For example,
test1.php
<?php
session_start() ;
$_SESSION['logPass']="whatever";
.
.
.
Your Code
.
.
.
?>
test2.php
<?php
session_start() ;
$pass = $_SESSION['logPass'];
echo $pass;
?>
Output
whatever

Please read session part.
I hope this is what you want.
Sep 26 '06 #2
naja
3 New Member
Hi skim,,
I'll provide u the 2 pages i've created using jsp javascript for login page... check it out... and let me know how can i do it in php....check only the code which is bold..so it'll be easy for u...ok

page 1......

<html>
<head>
<title>MRPL management Staff Association</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
@import url("images/css.css");
@import url("images/styles.css");
body {
background-color: #999999;
}
.style1 {color: #FFFFFF}
.style2 {font-size: 9px}
.style6 {font-size: 12px}
.style7 { font-size: 14px;
font-weight: bold;
}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0 ">
<!-- ImageReady Slices (template2.psd) -->
<table width="778" height="629" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td width="265"><ob ject classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macrom edia.com/pub/shockwave/cabs/flash/swflash.cab#ver sion=7,0,19,0" width="264" height="118">
<param name="movie" value="images/logo1.swf">
<param name="quality" value="high">
<embed src="images/logo1.swf" quality="high" pluginspage="ht tp://www.macromedia. com/go/getflashplayer" type="applicati on/x-shockwave-flash" width="264" height="118"></embed>
</object></td>
<td>
<img src="images/index1_02.gif" width="514" height="118" alt=""></td>
</tr>
<tr>
<td height="57" colspan="2" background="ima ges/index_03.jpg">& nbsp;</td>
</tr>
<tr>
<td height="153" colspan="2" valign="middle" style="border-bottom:bd2827 solid 1px;"><script type="text/javascript">


//Specify the slider's width (in pixels)
var sliderwidth="77 8px"
//Specify the slider's height
var sliderheight="1 53px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=3
//configure background color:
slidebgcolor="# EAEAEA"

//Specify the slider's images
var leftrightslide= new Array()
var finalslide=''
leftrightslide[0]='<img src="images/image1.jpg" border=1>'
leftrightslide[1]='<img src="images/image2.jpg" border=1>'
leftrightslide[2]='<img src="images/image3.jpg" border=1>'
leftrightslide[3]='<img src="images/image4.jpg" border=1>'
leftrightslide[4]='<img src="images/image5.jpg" border=1>'

//Specify gap between each image (use HTML):
var imagegap=" "

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=5


////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=slide speed
leftrightslide= '<nobr>'+leftri ghtslide.join(i magegap)+'</nobr>'
var iedom=document. all||document.g etElementById
if (iedom)
document.write( '<span id="temp" style="visibili ty:hidden;posit ion:absolute;to p:-100px;left:-9000px">'+leftr ightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=doc ument.getElemen tById? document.getEle mentById("test2 ") : document.all.te st2
cross_slide2=do cument.getEleme ntById? document.getEle mentById("test3 ") : document.all.te st3
cross_slide.inn erHTML=cross_sl ide2.innerHTML= leftrightslide
actualwidth=doc ument.all? cross_slide.off setWidth : document.getEle mentById("temp" ).offsetWidth
cross_slide2.st yle.left=actual width+slideshow gap+"px"
}
else if (document.layer s){
ns_slide=docume nt.ns_slidemenu .document.ns_sl idemenu2
ns_slide2=docum ent.ns_slidemen u.document.ns_s lidemenu3
ns_slide.docume nt.write(leftri ghtslide)
ns_slide.docume nt.close()
actualwidth=ns_ slide.document. width
ns_slide2.left= actualwidth+sli deshowgap
ns_slide2.docum ent.write(leftr ightslide)
ns_slide2.docum ent.close()
}
lefttime=setInt erval("slidelef t()",30)
}
window.onload=f illup

function slideleft(){
if (iedom){
if (parseInt(cross _slide.style.le ft)>(actualwidt h*(-1)+8))
cross_slide.sty le.left=parseIn t(cross_slide.s tyle.left)-copyspeed+"px"
else
cross_slide.sty le.left=parseIn t(cross_slide2. style.left)+act ualwidth+slides howgap+"px"

if (parseInt(cross _slide2.style.l eft)>(actualwid th*(-1)+8))
cross_slide2.st yle.left=parseI nt(cross_slide2 .style.left)-copyspeed+"px"
else
cross_slide2.st yle.left=parseI nt(cross_slide. style.left)+act ualwidth+slides howgap+"px"

}
else if (document.layer s){
if (ns_slide.left> (actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=n s_slide2.left+a ctualwidth+slid eshowgap

if (ns_slide2.left >(actualwidth *(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left= ns_slide.left+a ctualwidth+slid eshowgap
}
}


if (iedom||documen t.layers){
with (document){
document.write( '<table border="0" cellspacing="0" cellpadding="0" ><td>')
if (iedom){
write('<div style="position :relative;width :'+sliderwidth+ ';height:'+slid erheight+';over flow:hidden">')
write('<div style="position :absolute;width :'+sliderwidth+ ';height:'+slid erheight+';back ground-color:'+slidebg color+'" onMouseover="co pyspeed=0" onMouseout="cop yspeed=slidespe ed">')
write('<div id="test2" style="position :absolute;left: 0px;top:0px"></div>')
write('<div id="test3" style="position :absolute;left:-1000px;top:0px" ></div>')
write('</div></div>')
}
else if (document.layer s){
write('<ilayer width='+sliderw idth+' height='+slider height+' name="ns_slidem enu" bgColor='+slide bgcolor+'>')
write('<layer name="ns_slidem enu2" left=0 top=0 onMouseover="co pyspeed=0" onMouseout="cop yspeed=slidespe ed"></layer>')
write('<layer name="ns_slidem enu3" left=0 top=0 onMouseover="co pyspeed=0" onMouseout="cop yspeed=slidespe ed"></layer>')
write('</ilayer>')
}
document.write( '</td></table>')
}
}
</script></td>
</tr>
<tr>
<td height="277" align="center" valign="top" bgcolor="0c5386 " class="date"><t able width="90%" border="0">
<tr>
<td align="center" valign="middle" class="text"><p align="center" class="title style1">Members Login</p>
<form name="form3" method="post" action="http://localhost:8080/mrpl/login.jsp" onSubmit = "return validate(this.f orm)">
<p class="style1">
<label>Login_Id &nbsp;
<input type="text" name="login_id" tabindex="1">
</label>
</p>
<p class="style1">
<label>Passwo rd
<input type="password" name="password" tabindex="2">
</label>
</p>
<p>
<span class="style1">
<LABEL></LABEL>
</span> <span class="style1">
<center>
<input type="submit" value="Submit" tabindex="3" name="Submit">
</center>
&nbsp;&nbsp; </span></p>
</FORM>
</td>
</tr>
</table>
<p><span class="style7"> MRPL <br>
Management </span><span class="style7"> Staff Association</span><br>
(Registration No. TUA 484: 2005)</p>
<p class="style6"> Room No.4, <br>
1st Floor, MRPL Employees Club, <br>
Kuthethoor
P.O., Mangalore 575 030.<br>
Karnataka India</p>
<p class="style6"> Contact Nos.: <br>
0824 2236649 (Dir) <br>
2270400 Extn 4649 </p></td>
<td width="517" height="277" align="center" valign="top" bgcolor="006cb0 " class="text style1"><TABLE width="90%" align="center">
<TBODY>
<TR>
<TD align="center" valign="middle" class="text style1"><p align="left" class="title style1">About Us</p>
<p align="center"> <em>Real strength never impairs beauty or harmony, but it often bestows it; and in everything imposingly beautiful, strength has much to do with the magic.</em></p>
<p align="right">< em>- Herman Melville</em></p>
<p align="justify" > MRPL management staff association is a body comprising of management staff of Mangalore Refinery and Petrochemicals Ltd. At present there are more than 270 management staff personnel who are members of this August body. It is mutual trust, even more than mutual interest that binds the members of our association<br>
The main objectives of the association are</p>
<ul>
<li>
<div align="justify" > To have direct and effective channel of communication with the Management and there by improve the efficiency, profitability and development of the Company.</div>
</li>
<li>
<div align="justify" >
To discuss, debate and ensure improvement of welfare and service conditions of the members of the Association.</div>
</li>
<li>
<div align="justify" >
To foster unity, goodwill, understanding and harmony among the<br>
members and promote mutual help and appreciation.</div>
</li>
<li>
<div align="justify" >
To promote harmonious relation between management and non- management staff.</div>
</li>
<li>
<div align="justify" >
To seek affiliation with All India Organization/Association of the management staff in the Oil industry having similar objectives.</div>
</li>
</ul></TD>
</TR>
<TR>
<TD align="center" valign="middle" class="text style1">&nbsp;</TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<tr>
<td height="24" colspan="2" background="ima ges/index_07.jpg" class="text style1"><div align="center" class="style2"> Copyright @ MRPL Management Staff Association, all rights reserved designed by : Jyothi Software Solutions </div></td>
</tr>
</table>
</body>
</html>
Sep 27 '06 #3
naja
3 New Member
thi is the second page.....

page 2......

<%@ page import="java.sq l.*" %>
<%

String log_id = request.getPara meter("login_id ");
String pwrd = request.getPara meter("password ");
//out.println(log inname)
String uname;
String upwd;

try
{

Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
Connection con = DriverManager.g etConnection("j dbc:odbc:mrplka na","tiger","ma nager");
Statement st = con.createState ment();
ResultSet rs = st.executeQuery ("select * from logintbl");

while(rs.next() )
{
uname=rs.getStr ing(1);
upwd=rs.getStri ng(2);


if(log_id.equal s(uname) && pwrd.equals(upw d))
{
response.sendRe direct("http://localhost:8080/mrpl/news.html");
}
else
{%>
<script language="javas cript">
alert("WRONG USER NAME OR PASSWORD.");

document.locati on.href="http://localhost:8080/mrpl/index.html";
</script>
<% }

}


}




catch(Exception e)
{
out.println(e.g etMessage());
}
%>
Sep 27 '06 #4
skim
9 New Member
I think you need to read a session document.
http://www.w3schools.com/php/php_sessions.asp
http://www.tizag.com/phpT/phpsessions.php

In PHP, you need containers to send parameters to next pages.
So, you want to send "login_id" and "password" on 'POST' method to the next page, then do this.

session_start() ; // Start Session. It's required.
$_SESSION['login_id'] = $_POST['login_id']; //Put 'login_id' text from the form into the session container
$_SESSION['password'] = $_POST['password']; //Put 'password' into the another container as the 'login_id'
Done!!!

The session will remember values in everywhere on your script.
Now, how to open the session variables
Any next pages.
session_start() ; // Start Session. It's required.
$login_id = $_SESSION['login_id']; // indicate what 'login_id' value is
$password = $_SESSION['password']; // indicate what "password' value is
Done!!!

P.S: You do not need 2 pages to check the legal user. Try to use this way.
session_start() ;
if(isset($_POST['Submit']))
{
//check user here and if the user is legal
if(user is legal)
{
//if you still want to send user id to next page
$_SESSION['login_id'] = $_POST['login_id'];
$_SESSION['password'] = $_POST['password'];
// do whatever or go to next page
}
else
{
print "Sorry you are not legal user";
}

}

I hope this helps you.
Sep 27 '06 #5

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

Similar topics

8
10662
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad Request" was the original error msg now that I reinstalled iislockdown and urscan I get "The parameter is incorrect." If I use the get method with this form it works just fine on everything. I can't say for certain but I think this problem started...
7
2315
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site. The only reason I know that is happening is because I keep track of the pages executed by the user to see how they have traversed the site. Has anyone every seen anything like this before? Regards, Aaron Prohaska
10
6959
by: Bo Rasmussen | last post by:
Hi, I have a problem : I have a form with some buttons. When one of these buttons is pressed a new URL with some parameters to e.g. delete something from a database. The problem is that when the user presses refresh that same URL is fired with the parameters to delete again - this sometimes gives strange behaviour. Is there any way that I can stip of parameters when reloading a page such that only the webpage is deleted e.g. ...
3
45983
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem to find a reference to request or response objects in JavaScript either in Google Groups or O'Reilly's "JavaScript the Definitive Guide" (surely it should be in the latter, huh?) I know I could use a hidden form element but the data would be a...
5
15375
by: Daniel | last post by:
how to detect who redirects traffic to a aspx page? is this info passed along in request object or can sites anonymously redirect traffic to other sites?
0
2535
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind of an aspx page and the presentation of the page to the user? 2~ is it true that the engine takes data from the Request.Form and puts them
6
3822
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
6
5730
by: Steve | last post by:
Hi there, I'm trying to create a new website that will have a common aspx file serve as a template. I want all other pages to use this file and 'inject' their own content i.e. user controls, static html etc. The thing is that I don't actually want these other 'pages' to exist on disk (since I don't want to have to maintain multiple aspx pages - just the content). I basically want an XML file that defines the content 'page' path,...
1
3833
by: C. (http://symcbean.blogspot.com/) | last post by:
Hi all, I'm dabbling with an Ajax datagrid control and am looking to see if I can make it a bit more sophisticated. I've got a PHP script, let's call it page.php which renders a page with a fancy dhtml table (http://dhtmlx.com/docs/products/dhtmlxGrid/ index.shtml) this connects to another script which provides the XML datafeed to populate the table, lets call it xmlfeed.php
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11123
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
10734
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...
0
10407
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...
0
9567
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3230
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.