Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-14-2009, 03:28 PM Help with a form
fog
fog's Avatar
Experienced Talker

Posts: 47
Location: Florida
Trades: 0
I am trying to learn php and have been going crazy trying to find a solution to what I need to do. I have been googling this and looking at php.net and just can't find what my problem is.

I have to submit a form to a database with name, address and all of the normal things, no problem, I have that part done and works fine.

I would like to have the data the party entered in a new form on a page and then do the following:
Take one field and multiply that by a number, then add that total to another field to get a grand total. I thought that I could get the required fields by using the $_POST array by using:
value= <?php echo $_POST["fname"]?> in the new from field but that is not working. Is this possible?

After the new form is populated a new field will show the grand total by using the values from the array. Am I approaching this correctly? Any suggestions?

Any help or kick in the right direction will be apprectiated.
__________________
Every artist was first an amateur.
Ralph Waldo Emerson
fog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-14-2009, 05:47 PM Re: Help with a form
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Yes, it is possible to echo the variable into the value attribute of the new form field, just as you did above.
PHP Code:
<input type="text" value="<?php echo $my_variable?>">
or
<input type="text" value="<?php echo $_POST['my_variable']; ?>">
<!-- But please note that you should validate all $_POST data before using it -->
It's probably better if you post your code, together with any error messages you might recieve. Then it'll be easier to spot what's wrong with it.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-17-2009, 12:00 PM Re: Help with a form
Webmaster_Alex's Avatar
Novice Talker

Posts: 4
Name: Alex Flom
Trades: 0
Try to change this:
value= <?php echo $_POST["fname"]?>
into this:
value= "<?php echo $_POST['fname'];?>"

*Make sure that the name of the text box in the form is raelly: fname
__________________
My Blog: Webmaster Video School

Please login or register to view this content. Registration is FREE
Webmaster_Alex is offline
Reply With Quote
View Public Profile
 
Old 12-17-2009, 02:50 PM Re: Help with a form
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Quote:
Originally Posted by Webmaster_Alex View Post
Try to change this:
value= <?php echo $_POST["fname"]?>
into this:
value= "<?php echo $_POST['fname'];?>"

*Make sure that the name of the text box in the form is raelly: fname
Changing double quotes (") to single quotes (') won't make any difference in this case
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Help with a form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19686 seconds with 12 queries