PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 24th, 2005, 03:25 AM
HowdeeDoodee HowdeeDoodee is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 HowdeeDoodee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 50 m 18 sec
Reputation Power: 0
Pass a value to a text box on php form

How can I pass a value to a text box on a php form from an html form?

Reply With Quote
  #2  
Old February 24th, 2005, 07:37 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
PHP Code:
<input type="text" value="<?=$phpVariable;?>"

Reply With Quote
  #3  
Old February 24th, 2005, 11:23 AM
HowdeeDoodee HowdeeDoodee is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 HowdeeDoodee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 50 m 18 sec
Reputation Power: 0
Not doing so hot here in AZ.

The following form is placed inside my php routine. $VariablePassed is the variable passed from the search or submit form in the http address.

I get a
Parse error: parse error, unexpected '<' message
when I use the following statements in the form below

<form method="GET" action="TheForm5.php">

<p><b><font size="4" face="Arial">The Form5</font></b></p>

<input type="text" value="<?=$VariablePassed;?>">

</form>

Other input type= statements I have tried have been the following with the same resuts.

<p><input type="text" input name="SeeAlso" size="20" value=<? echo $SeeAlso?><input type="submit"></p>

<p><input type="text" input name="SeeAlso" size="20" value= <echo $SeeAlso><input type="submit"></p>

<p><input type="text" input name="SeeAlso" size="20" value=<echo $SeeAlso><input type="submit"></p>

<input type="text" value="<?=$SeeAlso;?>"><input type="submit"></p>

<p><input type="text" value="<?=$SeeAlso;?>"><input type="submit"></p>

<input type="text" value="<?=$SeeAlso;?>">

<p><input type="submit"></p>

input type="text" value="<?=$SeeAlso;?>"

<p><input type="submit"></p>

<p><input type="text" value="?=$SeeAlso;?"><input type="submit"></p>

<p><input type="text" value="?=$SeeAlso;?"></p>

<input type="text" value="<?=$SeeAlso;?>">


Reply With Quote
  #4  
Old February 24th, 2005, 11:38 AM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
You probably have some PHP code that you're not closing out of before you start your HTML:

PHP Code:
<?
  $var 
'foo';
  
?>
  
  <form>
  <input type="text" value="<?=$foo;?>">
  </form>


Make sure you have that '?>' before your opening <form> tag.

Also, a note on syntax: Whether the echo shortcut <?=$foo?> works is determined by the short_open_tag ini setting. <? echo $foo; ?> will always work, so if you're writing code that needs to be highly portable, you're probably better off using the full echo. That said, most of my code doesn't have to be that portable, so I use the short form.

Reply With Quote
  #5  
Old February 24th, 2005, 12:48 PM
HowdeeDoodee HowdeeDoodee is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 HowdeeDoodee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 50 m 18 sec
Reputation Power: 0
Madpawn. You are correct. Excellent!!!!!

Here is the working code for archival purposes.

<BODY>
<?php
$var = 'foo';
?>

<p>&nbsp;</p>
<form method="GET" action="The Form.php">
<p><b><font size="4" face="Arial">Search Other</font></b></p>
<p><input type="text" value="<?=$Variable1;?>" input name="Var1" size="20"><input type="submit"><input type="reset" value="Reset" name="B2"></p>
</form>
<p>&nbsp;</p>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Pass a value to a text box on php form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT