Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2007, 12:35 AM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP5: Ch 3, p. 102-105

Hi all,

I am having some trouble with the loan application script. I think it has to do with $LoanAllowance, but I am unsure. The script seemed to be working fine, except that there is no way to have any loan accepted.

Below is my code for loan.html:

Code:
<form method="POST" action="loan.php">
First Name:
<input name="FirstName" type="text"><br />
Second Name:
<input name="LastName" type="text"><br />
Age:
<input name="Age" type="text" size="3">
<br /><br />
Address:
<textarea name="Address" rows="4" cols="35">
</textarea>
<br />
<br />
What is your current salary?
<select>
    <option value="0">Under $10,000</option>
    <option value="10000">$10,000 to $25,000</option>
    <option value="25000">$25,000 to $50,000</option>
    <option value="50000">Over $50,000</option>
</select>
<br /><br />
How much do you want to borrow?
<br /><br />
<input name="Loan" type="radio" value="1000">Our $1,000 package is 

charged at a moderately ridiculous interest rate.
<br />
<input name="Loan" type="radio" value="5000">Our $5,000 package is 

charged at a completely ridiculous interest rate.
<br />
<input name="Loan" type="radio" value="10000">Our $10,000 package is 

charged at a absolutely ludicrous interest rate.
<br /><br />
<input name="reset" type="reset" value="Reset the application form">
<input name="submit" type="submit" value="Submit the application form">
</form>
And for loan.php:
Code:
<?php

    $SalaryAllowance = $_POST['Salary']/5;
    $AgeAllowance = ($_POST['Age']/10 - ($_POST['Age']%10)/10)-1;
    $LoanAllowance = $SalaryAllowance * $AgeAllowance;
    echo "Loan wanted: " . "$_POST[Loan]" . "<br />";
    echo "Loan we will allow: " . "$LoanAllowance" . "<br />";

    if ($_POST['Loan'] <= $LoanAllowance) echo "Yes, " . "$_POST[FirstName]" . " " . "$_POST[LastName]" . ", we 

are delighted to accept your application";

    if ($_POST['Loan'] > $LoanAllowance) echo "Sorry, " . "$_POST[FirstName]" . " " . "$_POST[LastName]" . ", we 

regret to inform you that we will not be taking advantage of your need for cash at this time.";

?>
Also, I was wondering why I only have to put inverted commas in sometimes, eg, "$_POST[Loan]" vs "$_POST['Age']"?

Thanks in advance,
JaneDean

 
Old January 3rd, 2007, 09:44 AM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I figured this one out. I forgot to actually name one of the form elements. Man, do I feel stupid. :)

 
Old January 31st, 2007, 02:15 PM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you find an answer to your "inverted commas" (single quotes) question?

I ask a similar question in a recent post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
show numeric value as 102,34 (EURO money) crmpicco Perl 1 May 11th, 2008 07:05 AM
does not work register.php in ch 11 begining php5 tanvir_math BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 February 7th, 2007 05:03 PM
Pro PHP5, Ch.15, Class file usage BillD Pro PHP 0 April 7th, 2005 11:08 PM
Professional PHP5 Ch. 15 Custom Session Handler superrobotpope Pro PHP 4 February 4th, 2005 08:32 PM
Ch. 4 & Ch. 12 athena BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 23rd, 2004 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.