Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
How to give back button in php page

 
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum
Author Message
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: How to give back button in php page Reply with quote

Hi all,
Me back again with a problem. The best place to find some real help.
I am designing a form using php. Now after a user logs in, the user will be given a form of 4 pages. Now, as I am using session so whenever the user clicks the back button it gives a prompt to refresh page as I just gave the name of the prev page in back button's link. So when I refresh it then gives the preious page without the data.
How to easily back and forth between the form pages?
Hope I made myself clear.

Thanks in advance.

-tanveer
Tue Feb 28, 06 8:39 am
Back to top
tanveer View user's profile Send private message
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Change form data from POST to GET. Let us know.

-Dinangkur
_________________
...we too are stardust...
Wed Mar 01, 06 10:58 pm
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: Reply with quote

Great. Thank u very much.
It works.
One more thing, is there any way to see the previously filled data when Press back button?

-tanveer
Sat Mar 04, 06 3:09 am
Back to top
tanveer View user's profile Send private message
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Which "back button", browser or implementated by you?

-Dinangkur
_________________
...we too are stardust...
Sat Mar 04, 06 10:51 pm
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: Reply with quote

Implemented by me.

In the back button I just used this
<a href="name_of_previous_php_page">Back</a>
And in the Form POST I used GET. Thats it.
So, when I click Back the previously filled data is lost.

-tanveer
Sun Mar 05, 06 12:47 am
Back to top
tanveer View user's profile Send private message
maindeepak
Just In
Just In


Joined: 05 Apr 2006
Posts: 1

Post Post subject: Hi tanveer Reply with quote

Hi tanveer,

In place of <a href="name_of_previous_php_page">Back</a>
use javascript history(). i.e. <a href="JavaScript:history.back();">Back</a>


Thanks,
Keep Smiling
Thu Apr 06, 06 2:55 am
Back to top
maindeepak View user's profile Send private message Yahoo Messenger
tanveer
User
User


Joined: 21 Jun 2004
Posts: 85
Location: Dhaka,Bangladesh

Post Post subject: Reply with quote

Hi all:
maindeepak, that won't work, I tried.
I have done something like this:
Posting all data in the same page and everything deciding from that page.

General.php
Code:

<?php
session_start();

if( isset($_POST['submit']) || isset($_POST['submitnext']) )
{


   if($_GET['page'] == '1')
   {
      $_SESSION['page1'] = $_POST;
    
     if($_POST['submit'] == 'Next')
     {
       header('Location:page2.php');
     }
   }
   elseif($_GET['page'] == '2')
   {
      $_SESSION['page2'] = $_POST;
     if($_POST['submitnext'] == 'Next')
     {
        header('Location:page3.php');
     }
     else
     {
        header('Location:page1.php');
     }
    
   }
   else
   {
      $_SESSION['page3'] = $_POST;
     if($_POST['submit'] == 'Prev')
     {
        header('Location:page2.php');
     }    
   }

}

?>


page1.php

Code:

<?php
session_start();
?>
<form name="page" action="general.php?page=1" method="post">
<table width="50%"  border="0" align="center" bordercolor="#0033CC">
  <tr>
    <td><div align="right" class="style4">name</div></td>
    <td><input type="text" name="name" value="<?php echo $_SESSION['page1']['name']; ?>"></td>
  </tr>
  <tr>
    <td><div align="right" class="style4">roll</div></td>
    <td><input type="text" name="roll"  value="<?php echo $_SESSION['page1']['roll']; ?>"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>    <input type="submit" name="submit" value="Next"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right" class="style1">Page-1</div></td>
  </tr>
</table>
</form>


Page2.php
Code:

<?php
session_start();
?>

<form name="page" action="general.php?page=2" method="post">
<table align="center" width="50%"  border="0">
  <tr>
    <td><div align="right"><span class="style3">name</span></div></td>
    <td><input type="text" name="name" value="<?php  echo $_SESSION['page2']['name']; ?>"></td>
  </tr>
  <tr>
    <td><div align="right"><span class="style3">roll</span></div></td>
    <td><input type="text" name="roll"  value="<?php echo $_SESSION['page2']['roll']; ?>"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value="Prev">
    <input type="submit" name="submitnext" value="Next"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right" class="style3">Page-2</div></td>
  </tr>
</table>
</form>


page3.php
Code:

<?php
session_start();
?>
<form name="page" action="general.php?page=3" method="post">
<table width="50%"  border="1" align="center">
  <tr>
    <td><div align="right">name</div></td>
    <td><input type="text" name="name"  value="<?php echo $_SESSION['page3']['name'] ; ?>"></td>
  </tr>
  <tr>
    <td><div align="right">roll</div></td>
    <td><input type="text" name="roll" value="<?php echo $_SESSION['page3']['roll']; ?>"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value="Prev">
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right">page-3</div></td>
  </tr>
</table>
</form>

Wed May 03, 06 11:26 am
Back to top
tanveer View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group