PHP Equivalent to .Net .text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jbcook
Forum Newbie
Posts: 2
Joined: Fri Jul 22, 2005 8:47 pm

PHP Equivalent to .Net .text

Post by jbcook »

I'm a newly .net to PHP convert. Its going great so far, much lighter than .net. In .net, you could use server side code to assign a value to a textbox by using txtName.Text = "value". I know I can pass my PHP variable into a session, then pick it up with Javascript, then use JavaScript to set the value. However, I was wondering if there was a simpler way of accessing form fields without client side JavaScript. Of course, thats why .net is so heavy because its more intuitive. Thanks for the help!
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

I'm not sure exactly what you're asking, but if you want to simply put a value into a regular text box you can do something like

Code: Select all

echo "<input type=\"text\" name=\"txtName\" value=\"$valueToInsert\" />";
or

Code: Select all

echo "<textarea name=\"txtName\" rows=\"5\" columns=\"60\">$valueToInsert</textarea>\n";
I would be careful with statements like
Of course, thats why .net is so heavy because its more intuitive.
as its not entirely true and liable to start a flamewar. Its also the type of statement that could make some people not want to help you.
Last edited by nielsene on Fri Jul 22, 2005 10:23 pm, edited 1 time in total.
jbcook
Forum Newbie
Posts: 2
Joined: Fri Jul 22, 2005 8:47 pm

Post by jbcook »

Nope, thats not what I'm looking for. I don't think PHP can do it as easily as .Net. Not trying to start a flame war, but I've been a .Net developer for 3 years and only been doing PHP for a couple of months...the advantages of PHP is starting to outway .Net. Don't forget...just 2 months ago I would have been preaching about the wonders of .Net.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Well can you explain what you are trying to do then?

You say you want a replacement for a .net server-side thing, but then talk about JavaScript which is purely client-side. What are you trying to accomplish?
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

I *think* I might know what you mean (whoa, grammar).

<form method="post">
<input type="textbox" name="whatever">
</form>

Code: Select all

echo $_POST['whatever'];
Post Reply