The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Output information based on user id input:
Discuss Output information based on user id input: in the PHP Development forum on Dev Shed. Output information based on user id input: PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 19th, 2012, 11:17 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation 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?
|

December 19th, 2012, 12:06 PM
|
|
|
|
"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.
|

December 19th, 2012, 02:17 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
|
|
|
Sorry. Should have made that clearer. That's the bit I'm after.
|

December 20th, 2012, 03:50 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation 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>
|

December 20th, 2012, 04:46 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
|
|
|
I think i need the where function but it wont work for me??? any ideas?
|

December 21st, 2012, 08:17 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation Power: 0
|
|
|
no one?
|

December 21st, 2012, 08:41 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
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()?
|

December 21st, 2012, 08:55 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 25
Time spent in forums: 8 h 36 m 44 sec
Reputation 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>
|

December 21st, 2012, 09:04 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
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 ...
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|