Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Get price from DB echo different price

  1. #11
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Okay, makes more sense to me now. If you want the information sent to be secure, you can't use GET method.

    You could use something like this

    PHP Code:
    <script language="javascript">
    function bob()
    {
    document.forms["myform"].submit();
    }
    </script>


    <form action="" method="post" id="myform" name="myform">
    <input type="hidden" name="" value=" <?php echo $variable?> ">
    <input type="hidden" name="" value=" <?php echo $variable?> ">
     ?> ">
    </form>
    but it still wouldn't be secure because anyone can browse your pages source code. The most secure way (correct me if I'm wrong!) I can think to do this (easily) is using sessions.

  2. #12
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    36
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by keyboard1333 View Post
    Okay, makes more sense to me now. If you want the information sent to be secure, you can't use GET method.

    You could use something like this

    PHP Code:
    <script language="javascript">
    function bob()
    {
    document.forms["myform"].submit();
    }
    </script>


    <form action="" method="post" id="myform" name="myform">
    <input type="hidden" name="" value=" <?php echo $variable?> ">
    <input type="hidden" name="" value=" <?php echo $variable?> ">
     ?> ">
    </form>
    but it still wouldn't be secure because anyone can browse your pages source code. The most secure way (correct me if I'm wrong!) I can think to do this (easily) is using sessions.
    Yes maybe, i dont know how to use that thow.

  3. #13
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    PHP Code:
    <?php
    session_start
    ();
    $variable "hello";
    $_SESSION["price"] = $variable;
    ?>
    $variable is the value you want to pass over.


    on your second page

    PHP Code:
    <?php
    session_start
    ();
    echo 
    $_SESSION["price"];
    ?>

  4. #14
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    36
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by keyboard1333 View Post
    PHP Code:
    <?php
    session_start
    ();
    $variable "hello";
    $_SESSION["price"] = $variable;
    ?>
    $variable is the value you want to pass over.


    on your second page

    PHP Code:
    <?php
    session_start
    ();
    echo 
    $_SESSION["price"];
    ?>
    Thank you i'l try this, and if i whant to pass over more than one variable ex, ID, Name?

    and i still need to have this in a link to the answering form page?
    Last edited by PatrikIden; 11-24-2011 at 08:59 PM.

  5. #15
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    This bit goes on the page which you are accessing the database

    PHP Code:
    <?php 
    session_start
    (); 
    $variable "hello"
    $_SESSION["price"] = $variable
    ?>


    If you want to have more than one piece of information, you do this

    PHP Code:
    <?php 
    session_start
    (); 
    $variable "hello"
    $variable2 "hello2"
    $_SESSION["price"] = $variable
    $_SESSION["price2"] = $variable2
    ?>

    This should go at the top of the page.
    PHP Code:
    session_start(); 

    This has to go after you retrieve the value from the database that your trying to use. $variable (or what ever you want to call it) has to be the value you are trying to transfer over to another page
    PHP Code:
    $variable "hello"
    $variable2 "hello2"
    $_SESSION["price"] = $variable
    $_SESSION["price2"] = $variable2



    Note:You can call the variables anything you want.

  6. #16
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    36
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by keyboard1333 View Post
    This bit goes on the page which you are accessing the database

    PHP Code:
    <?php 
    session_start
    (); 
    $variable "hello"
    $_SESSION["price"] = $variable
    ?>


    If you want to have more than one piece of information, you do this

    PHP Code:
    <?php 
    session_start
    (); 
    $variable "hello"
    $variable2 "hello2"
    $_SESSION["price"] = $variable
    $_SESSION["price2"] = $variable2
    ?>

    This should go at the top of the page.
    PHP Code:
    session_start(); 

    This has to go after you retrieve the value from the database that your trying to use. $variable (or what ever you want to call it) has to be the value you are trying to transfer over to another page
    PHP Code:
    $variable "hello"
    $variable2 "hello2"
    $_SESSION["price"] = $variable
    $_SESSION["price2"] = $variable2



    Note:You can call the variables anything you want.

    OK i'm not realy getting this, how can this get the price from DB what ever the price is? (i mean it's the user that puts in the price when posting an add).
    Can i put somthing like this in $Variable <?php echo mysql_result($result,$i,"price"); ?>, i use this echo in my code now.
    Last edited by PatrikIden; 11-25-2011 at 06:16 PM.

  7. #17
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Instead of using echo, just store that value to one of the session variables:
    echo 'something;
    $var = 'something';


    However, honestly using sessions will get complicated if a user happens to be browsing two things at one time because you'll need to track everything and not get the variables confused. Sessions are available on all pages and there is only one session per site.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #18
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    36
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Hi, keyboard1333 did you send me an email? i recived a email dhat have some add in it. So i just have to ask if it is you that sent me taht mail just so i dont send the code to someone else.

    If it you thaen Thank you for getting in tuch.

    Regars

    /Patrik.

  9. #19
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Yep, I sent you that email...
    Sorry about the ad, it's one of incredimails dumb 'features'.
    I really should get a proper email program...

Bookmarks

Posting Permissions

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