#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0

    Output information based on user id input:


    output information based on user id input:

    Hi Guys, I'm looking to have a user put a referance number in a form and then redirect them to a new page where based upon the ref she has added the other fields for that row will be output.

    Eg: Page 1: Customer has form to input referance number:
    PHP Code:
    <form method="post" action="full_payment.php">
    1. Your Referance Number <input type="text" name="MKREF"/><br/>
    <
    input type="submit" name="submit"/>
    </
    form
    Page 2.
    PHP Code:
        <div id="homepage">
          <section id="services" class="clear">
            <article class="one_third">
            <h2>Full & Final Payment</h2>
            Thank you  [insert name here] <br>
            You can use PayPal to make your full payment here, Alternatively you can use one of our installment plans if you wish to spread the cost.<br>
            </p>
            
            </article>
            <article class="one_third">
             <h2>Full & Final Payment</h2>
            You can use PayPal to make your full payment here, Alternatively you can use one of our installment plans.<br><br>
            
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="M3QBVVQCANRHS">
    <table>
    <tr><td><input type="hidden" name="on0" value="Morgan Knightley Referance Num">Morgan Knightley Referance Number</td></tr><tr><td><input type="text" name="os0" maxlength="200" value="<?php echo $MKREF.''?>"></td></tr>
    <tr><td><input type="hidden" name="on1" value="SiP Referance Number">SiP Referance Number</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr>
    </table><br>
    <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online."><br>

    </form>
            </article>
    its the pull on the name i cant figure out... any help?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    50
    "the pull on the name"? I presume you mean where you have "insert name here" you want something like <?php echo $name; ?>

    Before that, you just need to have the code needed to extract from your storage (your database?) where you have associated the reference number to the name.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    Sorry. Should have made that clearer. That's the bit I'm after.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    this is what I have so far but i cant get it to out put the single name where i have requested the MKREF from the previous page.


    PHP Code:
     <?php 

     mysql_connect
    ("localhost""morgan""Im Not Stupid") or die(mysql_error()); 
     
    mysql_select_db("morgan_knightley") or die(mysql_error()); 

     
    $data mysql_query("SELECT NAME, REGISTRATION, SIPREF FROM SIPDEBTS WHERE MKREF = '$MKREF'"
     or die(
    mysql_error()); 
     while(
    $info mysql_fetch_array$data )) 
     
     
    ?> 


        <div id="homepage">
        
          <section id="services" class="clear">
            
            <article class="one_third">
            <h2>Full & Final Payment</h2>
            Thank you   <?php Print $info['NAME']; ?> <br>
            You have chosen to pay for your ticket in full for your car (Registration Number: $REGISTRATION )<br>
            You can use PayPal to make your full payment here, Alternatively you can use one of our installment plans if you wish to spread the cost.<br>
        

            </p>
            
            </article>
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    I think i need the where function but it wont work for me??? any ideas?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    no one?
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    I don't even see a definition for $MKREF. I hope you're not using the infamous register_globals?

    And what's with this half-done "while" loop? You do know that a single row can be fetched by simply calling mysql_fetch_array()?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    im not excellent at PHP.

    I have included code below which might help, basicly i want the user to put in their ref number, the database to get the ref that is assigned to and pull other bits of data that ref is assigned too:

    PHP Code:
    I can get it to carry over the MKREF number but can’t get it to output the details that ref is assigned to.



    Page 1 – full_payment_pass.php

    <form method="post" action="full_payment.php">

    1. Your Morgan Knightley Referance Number <input type="text" name="MKREF"/><br/>



    <input type="submit" name="submit"/>

    </form>


    Page 2: full_payment_catch.php

    <?php 


    $MKREF 
    $_POST['MKREF']; 


    ?>


    Page 3 full_payment.php

    <?php
    include 'full_payment_catch.php';
    ?>
    <?php 

    mysql_connect
    ("localhost""morgan_knightley""password here") or die(mysql_error()); 
     
    mysql_select_db("morgan_knightley") or die(mysql_error()); 

    $data mysql_query("SELECT NAME, REGISTRATION, SIPREF FROM SIPDEBTS WHERE MKREF = '$MKREF'"
     or die(
    mysql_error()); 
     while(
    $info mysql_fetch_array$data )) 
     
     
    ?> 


        <div id="homepage">

          <section id="services" class="clear">

            <article class="one_third">
                                    <h2>Full & Final Payment</h2>
                                    Thank you   <?php Print $info['NAME']; ?> <br>
                                    You have chosen to pay for your ticket in full for your car (Registration Number: $REGISTRATION )<br>
                                    You can use PayPal to make your full payment here, Alternatively you can use one of our installment plans if you wish to spread the cost.<br>
        

                                    </p>
            
            </article>
            <article class="one_third">
                    <h2>Full & Final Payment</h2>
                                    You can use PayPal to make your full payment here, Alternatively you can use one of our installment plans.<br><br>
            
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="M3QBVVQCANRHS">
    <table>
    <tr><td><input type="hidden" name="on0" value="Morgan Knightley Referance Num">Morgan Knightley Referance Number</td></tr><tr><td><input type="text" name="os0" maxlength="200" value="<?php echo $MKREF.''?>"></td></tr>
    <tr><td><input type="hidden" name="on1" value="SiP Referance Number">SiP Referance Number</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr>
    </table><br>
    <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online."><br>

    </form>
            </article>
  16. #9
  17. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    OK, so there's a single row for a particular MKREF value? In this case, simply call mysql_fetch_array( $data ) to fetch the row. You don't need a "while" loop, because you don't need to repeat the code multiple times.

    If it still doesn't work, output the query and see what it says:
    PHP Code:
    echo "SELECT NAME, REGISTRATION, SIPREF FROM SIPDEBTS WHERE MKREF = '$MKREF'";
    $data mysql_query("SELECT NAME, REGISTRATION, SIPREF FROM SIPDEBTS WHERE MKREF = '$MKREF'"
    Execute the query separately in phpmyadmin (or whatever it is you're using).

    There are several issues with your code regarding obsolete database functions and security holes, but it probably makes sense to do that later ...

IMN logo majestic logo threadwatch logo seochat tools logo