Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    regarding auto posting

    Hi,
    my problem is this?

    I have two textboxes in which i enter the values of A and B in the php page(first page).
    I should create another php page which will take these values, add them up in the second page and post the result in a third page automatically.
    Is there a way I could implement that .

    thanks,

    Ramesh

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Of course.:

    First page:
    PHP Code:
    <form action="page1.php" method="post">
    Text1: <input type="text" name="textbox2"/>
    <
    br/>
    Text2: <input type="text" name="textbox2"/>
    <
    input type="submit" value="Go!"/>
    </
    form
    Second page:
    PHP Code:
    <?php

    if( (!isset( $_POST['textbox2'] )) && (!isset( $_POST['textbox2'] )) ) {
      die(
    "You did not enter all required values, <a href=\"pageone.htm\">click here</a> to try again!");
    }

    $result $_POST['textbox1']+$_POST['textbox2'];

    // store them, or send them.
    ?>
    Now third page will depend on how the second page is written, are you going to store the value in a cookie or session, or database hashed by cookie or session or do you want it sent as a querystring etc.. there are a number of possibilities but that is essentially what you need, of course assuming I read your post correctly.
    Omnis mico antequam dominus Spookster!

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    thanks for replying to the post and giving your idea.
    I am not using a query string. I may use a database or sessions for the third page. Querystrings are not secure. Actually on the third page, i would like to display The result of A and B is C.
    how could i do that.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is your actual question or where do you need info on?

    - compute the value from the posted formfields?
    - store the resulting value in a sessionvariable?
    - print the value form the sessionvariable on the third page?

    As an aside: you're just computing something with values the client entered himself and the resulting value that you pass along in the QS is printed on screen anyway, so i don't see the securityissue here.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Using the query string, the result will appear on the browser as http://address.php?result=somevalue. I dont want the result to appear on the URL but be displayed in a different php page

    here is the code i worked on till now
    this is my first page where i pass the values.
    <code>
    <?php
    if (isset($_POST['submit'])) {

    print("<form method = POST action = 'research.php'>");

    $termCount= 2;
    print ("<table>");
    for ($n=0; $n < $termCount; $n++)
    {
    print ("<tr>");
    print ("<td>");
    $text = "'TextBox".$n."'";
    $termTextField = $text;
    print ("<INPUT TYPE='text' NAME=$termTextField VALUE='' cols='' size=''>");
    print ("</td>");
    print ("</tr>");
    }
    print ("</table>");



    print ("<input type='submit' name='submit' value='Search'>");
    print ("</form>");
    }
    else {
    // display form
    ?>
    <form method="post" action="<?php echo $PHP_SELF?>">
    <?php # <input type="text" name = "Text1"> ?>
    <input type="Submit" name="submit" value="Click Here to Search">
    </form>
    <?php
    }

    ?>
    </code>

    this is my second page from where i am trying to repost the result back to the first page or any other third page. Here i am using query strings to view the result. Is there a way of doing that without querystrings and using sessions or hidden variables?

    <code>
    <html>
    <head>
    <title>Search Processing</title>
    </head>
    <body>
    <table>
    <?php
    $count = 0;
    foreach ($_POST as $key=>$value)
    {
    $count = $count + $value;
    }
    print($count);
    Header("Location: repost.php?count=$count");
    ?>
    </table>
    </body>
    </html>
    </code>

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On your second page, store the posted variable inside a sessionvariable like
    PHP Code:
    session_start();   // on top of your page
    $_SESSION['test'] = $_POST['test']; 
    Then on other pages, you get the value like
    PHP Code:
    session_start();   // on top of your page
    $myvariable $_SESSION['test']; 
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just to let you know however, that a querystring will not be used with a "POST" form.... only GET forms will make a querystring, so you could use post....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •