Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 3rd, 2007, 12:35 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old January 3rd, 2007, 09:44 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
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. :)

Reply With Quote
  #3 (permalink)  
Old January 31st, 2007, 02:15 PM
Registered User
 
Join Date: Jan 2007
Location: PAINESVILLE, OH, .
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:25 PM.


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