473,499 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

redirecting the page using php

59 New Member
Hi all,

In my application there is a link in page 1 by name "plan", when it is clicked it directs to page2 which contains a form with many fields and submit button. When the user clicks the submit button, php and mysql code is written in page3 to store data in mysql. Here is code I am using

page2

Expand|Select|Wrap|Line Numbers
  1. <form name="plan" action="page3.php" method="POST">
  2. Name : <input type="text" name="Uname">
  3. Age: <input type="text" name="Uage">
  4. <input type="submit" value="GO"> 
  5. </form>
My problem is when the form is submitted in the page 2, I need to go to page 1 instead of page 3, but I can't write the php code in page 1 instead of page 3 because of some security reasons.
How can I solve this problem, how to redirect from page 3 to page 1 after execution of page 3 code. Can anybody help me

With regards

page3

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $Uname = $_POST['Uname'];
  3. $Uage = $_POST['Uage'];
  4.  
  5. $sql = "INSERT INTO user_info(user_name,user_age) VALUES('$Uname','$Uage')";
  6. $result = mysql_query($sql);
  7. ?>
Apr 10 '08 #1
7 2577
Markus
6,050 Recognized Expert Expert
Use a header() redirect.

[php]
# query mysql
header("Location: http://yoursite.com/page1.php");
[/php]

Regards :)
Apr 10 '08 #2
gubbachchi
59 New Member
Use a header() redirect.

[php]
# query mysql
header("Location: http://yoursite.com/page1.php");
[/php]

Regards :)
Thanks for the reply

I have used header() redirect but I am getting the warning
Warning: Cannot modify header information - headers already sent by (output started at /var/www/kilorie/kil_ver3/page3.php:3) in /var/www/kilorie/kil_ver3/page3.php on line 146

can you give me some hint
Apr 10 '08 #3
rpnew
188 New Member
Thanks for the reply

I have used header() redirect but I am getting the warning
Warning: Cannot modify header information - headers already sent by (output started at /var/www/kilorie/kil_ver3/page3.php:3) in /var/www/kilorie/kil_ver3/page3.php on line 146

can you give me some hint
Hi,
Post your page 3 code here...

Regards,
RP
Apr 10 '08 #4
gubbachchi
59 New Member
Hi,
Post your page 3 code here...

Regards,
RP

Hi,

here is my page3 code
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.       <?php
  4.  
  5.       $Uname = $_POST['Uname'];
  6.  
  7.       $Uage = $_POST['Uage'];
  8.  
  9.  
  10.  
  11.       $sql = "INSERT INTO user_info(user_name,user_age) VALUES('$Uname','$Uage')";
  12.  
  13.       $result = mysql_query($sql);
  14.  
  15.       ?>
  16. </body>
  17. </html>
Apr 10 '08 #5
Amzul
130 New Member
there is a target attribute to form alement one of them is _parent

i never use it before but sounds like it can help you,

on page 2
<form target="_parent" action="page3.php" method="post">
Apr 10 '08 #6
Markus
6,050 Recognized Expert Expert
there is a target attribute to form alement one of them is _parent

i never use it before but sounds like it can help you,

on page 2
<form target="_parent" action="page3.php" method="post">
No.

You are using a header after html has been output - big NONO!

Have a read about the header function on php.net

Regards.
Apr 10 '08 #7
TheServant
1,168 Recognized Expert Top Contributor
This is a cheap way of doing it, but if you want to redirect half way through your script you can output a meta refresh line in html:

[HTML]<meta http-equiv="refresh" content="2;url=http://mywebsite.com">[/HTML]

**The 2 means it will wait 2 seconds, you can change that to 0 if you want.

This can go anywhere and will do what you want I think.
Apr 10 '08 #8

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

Similar topics

3
2306
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the...
1
1846
by: Bilbo | last post by:
Hello, How do I programatically redirect a page in "another frame" using C# in ASP.NET? Server.Transfer redirects the current page...not a different frame. Thanks.
4
1481
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you...
4
2172
by: deepukutty | last post by:
HI all, I am using IE(Internet Explorer) as my default browser for asp.net application development. Today i faced a strange problem. When ever an exception occured in the page ....application...
7
1318
by: laredotornado | last post by:
Hello, I'm using PHP 4.4.4. After processing some data, I'd like to redirect to another page for further data processing. The way I'm redirecting right now is header("Location:...
1
1434
by: sreekeerthi | last post by:
hi friends...this is keerthi...i am doing a project where i want to redirect my page when ever the back button is clicked...for this i am using window.onbeforeunload method..and for page redirection...
41
3180
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
7
2436
by: vjayis | last post by:
Hi I have created a loginpage in which the user enters their username and password., the page gets loaded and validates the input and then it is redirectesd to the seeeion page using html...
4
2788
by: damiensawyer | last post by:
Hi, I'm trying to do something in global.asax that I would have thought to be quite simple. Basically, any request at all should get sent to another page. I actually got the code below from a...
6
29719
by: rpcchandu | last post by:
Hi Coders, I have to redirect from my server to the different server page by simulating the POST method submit from the Controller file, I tried using post_via_redirect, but could not succeed......
0
7012
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
7180
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,...
1
6901
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
7392
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...
0
5479
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,...
1
4920
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...
0
4605
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...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
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 ...

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.