| | |
text field values to php variable.......
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
This is probably a stupid question, but I am new to this stuff and need some help. I have a form with a text box and a submit button, and I want to pass the user-entered contents of the text box to a php variable ($size) when the user clicks the submit button. how do i do this??? any help is greatly appreciated. i can post my code if you think that will help just ask me.
Henry Phillips
Web Programmer
Adirondack Area Network, LLC
Web Programmer
Adirondack Area Network, LLC
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
Use $_POST['fieldname']
You said you're a beginner, so I wrote a very short description on how the whole process works. You may already be familiar with the basics of forms, but if not, read on. Don't be afraid to do Google searches, either. Remember, you're a web developer, your browser should be already RUNNING. (-:
Take this code snippet: (Which is not guaranteed to be error free, it's for example purposes only.)
The first several lines are a simple basic input form. We're passing variables by the POST method, which keeps them from being appended to the URL on submit. (There's also GET)
When the user clicks on "Submit" (or "Submit Query" because I didn't give the button a label), the browser will load the file indicated by
The script will then start executing at the
You said you're a beginner, so I wrote a very short description on how the whole process works. You may already be familiar with the basics of forms, but if not, read on. Don't be afraid to do Google searches, either. Remember, you're a web developer, your browser should be already RUNNING. (-:
Take this code snippet: (Which is not guaranteed to be error free, it's for example purposes only.)
PHP Syntax (Toggle Plain Text)
<form action="example.php" method="POST"> <input type="text" name="input_value"> <input type="submit" name="submit"> <?php if (isset($_POST['submit'])) { // Execute this code if the submit button is pressed. $formvalue = $_POST['input_value']; } ?>
The first several lines are a simple basic input form. We're passing variables by the POST method, which keeps them from being appended to the URL on submit. (There's also GET)
When the user clicks on "Submit" (or "Submit Query" because I didn't give the button a label), the browser will load the file indicated by
action=, which for the sake of this example is the one with the form.The script will then start executing at the
if (isset($_POST['submit'])) line, as the submit button was pressed. To access form values, you'd use $_POST['name']. www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
Join Date: Jun 2009
Posts: 1
Reputation:
Solved Threads: 0
index.html
Page.php
html Syntax (Toggle Plain Text)
<html> <body> <form action="page.php" method="post"> <input type="text" name="fname" /> <input type="text" name="age" /> <input type="Submit" name="Submit"> </form> </body> </html>
Page.php
php Syntax (Toggle Plain Text)
<html> <body> <?php $name = $_POST["fname"]; ?> <?php $age = $_POST["age"]; ?> Welcome <?php echo $name; ?><br /> You are <?php echo $age; ?> </body> </html>
Last edited by peter_budo; Jun 3rd, 2009 at 1:27 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- how to access accessing PHP variable in JavaScript (PHP)
- Searching a Text Field in a JList (Java)
- Filtering My sql through Php using drop down menu and text field (PHP)
- DOB field-how to use text field and pop out calendar same time? (ASP)
- Output MySQL text field formatted (PHP)
- How Can I Pass A PHP Variable From One .php page to another (PHP)
Other Threads in the PHP Forum
- Previous Thread: zipcodes packages
- Next Thread: how to create a link in a view page:
Views: 7003 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search searchbox select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





