problem with page redirect and data insertion together

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boss1
    New Member
    • Sep 2007
    • 45

    problem with page redirect and data insertion together

    Hi all,

    i m having a problem with inserting data in oracle db.
    When i use form action =(call self page) then data is inserting properly.But problem with when using form action=(Another _page).data is not insering into database.For ur kind infromation i m using oracle db and php for my application.

    sample code:
    [code=php]
    <form action="welcome .php" method="post">
    Name: <input type="text" name="name" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form>[/code]

    pls can any one help me.

    Thanks
    Last edited by pbmods; Aug 13 '08, 11:11 AM. Reason: Added CODE tags.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    In which page is the code that inserts the values in the database? That's the one you have to call if you want the values to be inserted.

    Comment

    • boss1
      New Member
      • Sep 2007
      • 45

      #3
      hi,
      Thanks for reply.

      My fisrt page is "test.php" from where i m trying to insert data
      After press on submit button form data will store in db and a success massege will show on the "wlcome.php"pag e.
      [code=html]
      <html>
      <body><form action="welcome .php" method="post">
      Name: <input type="text" name="name" />
      Age: <input type="text" name="age" />
      <input type="submit" />
      </form></body>
      </html> [/code]

      so pls help me how to divert the page to "wlcome.php " as well as data will insert in to db.

      Thanks
      Last edited by pbmods; Aug 13 '08, 11:11 AM. Reason: Added CODE tags.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        header ?

        Comment

        • boss1
          New Member
          • Sep 2007
          • 45

          #5
          hi,
          Thanks for ur cooperation.

          it willbe help for me if u make it clear in my given example for how to use "header"to redirect the page into welcome.php.

          thanks again

          Comment

          • boss1
            New Member
            • Sep 2007
            • 45

            #6
            hei,

            i need ur help wthh my specified problem previously disscussed.

            it's urgent for me so, pls help me.

            Thanks

            Comment

            • boss1
              New Member
              • Sep 2007
              • 45

              #7
              problem with page redirect and data insertion together

              Hi all,

              i m having a problem with inserting data in oracle db.
              When i use form action =(call self page) then data is inserting properly.But problem with when using form action=(Another _page).data is not insering into database.For ur kind infromation i m using oracle db and php for my application.

              sample code:

              [code=html]
              <form action="welcome .php" method="post">
              Name: <input type="text" name="name" />
              Age: <input type="text" name="age" />
              <input type="submit" />
              </form>[/code]
              the above code not data inserting but page is redirecting.

              so how to insert data aswell as redirect the page in welcome.php ?
              pls can any one help me.

              Thanks
              Last edited by pbmods; Aug 16 '08, 02:04 PM. Reason: Added CODE tags.

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Show the code you use to insert on welcome.php

                Comment

                • samikhan83
                  New Member
                  • Sep 2007
                  • 33

                  #9
                  hi......
                  1. U R getting some error ...... for page not found.... if yes write the proper action for form...

                  2. check weather ur getting all ur required data for ur query...... by echoing or printing the data.....

                  3. check ur query with the database...

                  4. using PHP_SELF is better than using form action.....

                  5. if none of the above then paste ur code.....

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    Originally posted by samikhan83
                    4. using PHP_SELF is better than using form action.....
                    That would depend on what you are attempting to do. What is "better" will always depend on the circumstance.
                    Not to mention that even if you use PHP_SELF, you are still using the form action ;)

                    But, to the OP's problem.
                    Whether or not you are posting the data to the current page or any other page, it shouldn't make the slightest difference. Any decent browser should simply fuse the POST data into the request before sending it.

                    I would bet the problem would be in your server-side script, the one that is meant to process the data into whatever database you are using.

                    Show us that code please, and we will do what we can to help you figure out a solution.

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      Originally posted by samikhan83
                      hi......
                      1. U R getting some error ...... for page not found.... if yes write the proper action for form...

                      2. check weather ur getting all ur required data for ur query...... by echoing or printing the data.....

                      3. check ur query with the database...

                      4. using PHP_SELF is better than using form action.....

                      5. if none of the above then paste ur code.....
                      Please review the posting guidelines:
                      Do not use leet speak or text speak, they are not Clear English

                      Comment

                      • boss1
                        New Member
                        • Sep 2007
                        • 45

                        #12
                        hi Atli,

                        Thank u for ur cooperation.
                        Here is my code :
                        [code=php]
                        <html>
                        <head><head>
                        code:(text)
                        <?
                        if ($c=ocilogon("a a","bb","ccc "))
                        //echo"successful ly connected to database.\n";
                        ?>

                        <?
                        $insert="insert into member_tbl(id,n ame,age) values('".$_POS T['id']."','".$_POS T['name']."','".$_POS T['age']."')";


                        $insertparse=oc iparse($c,$inse rt);
                        ociexecute($ins ertparse);

                        ?>

                        <body>
                        <form action="welcome .php" method="post" name="t1">

                        Memberid:<input type="text" name="id" />
                        Name: <input type="text" name="name" />
                        Age: <input type="text" name="age" />
                        <input type="submit"na me="submit" value="Submit" />

                        </form
                        </body>
                        </html>
                        [/code]
                        When i prees submit button,link goes to welcome.php page.but data is not inserting.
                        But if i use <form action="<?=$HTT P_SERVER_VARS['PHP_SELF']?>" NAME="s1" method="post"> then data is inserting properly but link dones not goto the welcome.php page.

                        Pls provide me a proper solution.

                        Thanks
                        Last edited by pbmods; Aug 18 '08, 01:40 PM. Reason: Added CODE tags.

                        Comment

                        • Markus
                          Recognized Expert Expert
                          • Jun 2007
                          • 6092

                          #13
                          Originally posted by boss1
                          hi Atli,

                          Thank u for ur cooperation.
                          Here is my code :
                          [code=php]
                          <html>
                          <head><head>
                          code:(text)
                          <?
                          if ($c=ocilogon("a a","bb","ccc "))
                          //echo"successful ly connected to database.\n";
                          ?>

                          <?
                          $insert="insert into member_tbl(id,n ame,age) values('".$_POS T['id']."','".$_POS T['name']."','".$_POS T['age']."')";


                          $insertparse=oc iparse($c,$inse rt);
                          ociexecute($ins ertparse);

                          ?>

                          <body>
                          <form action="welcome .php" method="post" name="t1">

                          Memberid:<input type="text" name="id" />
                          Name: <input type="text" name="name" />
                          Age: <input type="text" name="age" />
                          <input type="submit"na me="submit" value="Submit" />

                          </form
                          </body>
                          </html>
                          [/code]
                          When i prees submit button,link goes to welcome.php page.but data is not inserting.
                          But if i use <form action="<?=$HTT P_SERVER_VARS['PHP_SELF']?>" NAME="s1" method="post"> then data is inserting properly but link dones not goto the welcome.php page.

                          Pls provide me a proper solution.

                          Thanks
                          You're not understanding how form submition works; the 'action' attribute of the form is where all the data from the form is sent - in your case 'welcome.php'. What you seem to be thinking is that when the forum is submitted the code on the page with the form is then run - this isn't how it works. You need to relocate the code from your form page to 'welcome.php'.
                          Furthermore, you could just add in a redirect to your existing code and keep the 'action' attribute as PHP_SELF.

                          [php]
                          <?
                          $insert="insert into member_tbl(id,n ame,age) values('".$_POS T['id']."','".$_POS T['name']."','".$_POS T['age']."')";


                          $insertparse=oc iparse($c,$inse rt);
                          ociexecute($ins ertparse);

                          // redirect: no output can come before this
                          header("Locatio n: /welcome.php");
                          // you could alternatively output a meta refresh (uncomment to do so)
                          //echo '<meta http-equiv="refresh" content="2; url=/welcome.php">'

                          ?>
                          [/php]

                          Originally posted by boss1
                          hi Atli,

                          Thank u for ur cooperation.
                          Here is my code :
                          Yeh.. you're welcome ¬_¬

                          Comment

                          • Markus
                            Recognized Expert Expert
                            • Jun 2007
                            • 6092

                            #14
                            boss1, it is a forum rule that when you post code you use CODE tags. Here is an example:

                            [code]
                            // code goes here
                            <?php
                            echo 'using code tags!';
                            ?>
                            [/code]

                            Which makes it considerably easier to read!

                            Code:
                            // code goes here
                            <?php
                            echo 'using code tags!';
                            ?>

                            Comment

                            • pbmods
                              Recognized Expert Expert
                              • Apr 2007
                              • 5821

                              #15
                              Boss1, you've already been asked to start using CODE tags (see Markus's previous post for more information).

                              This message serves as your official warning. Continued violation of the site Posting Guidelines will result in account suspension.

                              If you have any questions or concerns, feel free to contact me anytime.

                              Thanks for your time.

                              pbmods

                              Comment

                              Working...