473,396 Members | 1,864 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,396 software developers and data experts.

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

3
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 39340
skim
9
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
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"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=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="http://www.macromedia.com/go/getflashplayer" type="application/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="images/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="778px"
//Specify the slider's height
var sliderheight="153px"
//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=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(imageg ap)+'</nobr>'
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftr ightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+" px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slideme nu2
ns_slide2=document.ns_slidemenu.document.ns_slidem enu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=fillup

function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style. left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style .left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.styl e.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style .left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshow gap

if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshow gap
}
}


if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';hei ght:'+sliderheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+sliderwidth+';hei ght:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
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.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
</script></td>
</tr>
<tr>
<td height="277" align="center" valign="top" bgcolor="0c5386" class="date"><table 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.form)">
<p class="style1">
<label>Login_Id&nbsp;
<input type="text" name="login_id" tabindex="1">
</label>
</p>
<p class="style1">
<label>Password
<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="images/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
thi is the second page.....

page 2......

<%@ page import="java.sql.*" %>
<%

String log_id = request.getParameter("login_id");
String pwrd = request.getParameter("password");
//out.println(loginname)
String uname;
String upwd;

try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mrplkana"," tiger","manager");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from logintbl");

while(rs.next())
{
uname=rs.getString(1);
upwd=rs.getString(2);


if(log_id.equals(uname) && pwrd.equals(upwd))
{
response.sendRedirect("http://localhost:8080/mrpl/news.html");
}
else
{%>
<script language="javascript">
alert("WRONG USER NAME OR PASSWORD.");

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

}


}




catch(Exception e)
{
out.println(e.getMessage());
}
%>
Sep 27 '06 #4
skim
9
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
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...
7
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....
10
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...
3
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...
5
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
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...
6
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...
6
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,...
1
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...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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,...
0
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...
0
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...

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.