| | |
echo in form input value
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 14
Reputation:
Solved Threads: 0
This is driving me crazy and should be very easy. I am trying to pre-fill an html form with session data using echo. I can compile and run but the form field contains a / if the session data is blank. How can I get rid of the /
Heres the code:
I have tried several combinations of '"` etc and it seems I am just missing the obvious. Thanks in advance - anyone.
Heres the code:
PHP Syntax (Toggle Plain Text)
<input name="fname" type="text" class="textfield" id="fname" value = <?php echo $_SESSION["namevalue"]; ?> />
I have tried several combinations of '"` etc and it seems I am just missing the obvious. Thanks in advance - anyone.
Hi andym67 and welcome to DaniWeb 
A better approach is this:
or:

A better approach is this:
php Syntax (Toggle Plain Text)
if(isset($_SESSION["namevalue"])) $val = $_SESSION["namevalue"]; else $val = ""; // maybe do some validation on $val here echo "<input name='fname' type='text' class='textfield' id='fname' value='$val' />";
php Syntax (Toggle Plain Text)
<?php if(isset($_SESSION["namevalue"])) $val = $_SESSION["namevalue"]; else $val = ""; // maybe do some validation on $val here ?> <input name="fname" type="text" class="textfield" id="fname" value="<?php echo $val; ?>" />;
Last edited by darkagn; Sep 9th, 2009 at 8:54 pm.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. Look at your value attribute,:
This should be:
php Syntax (Toggle Plain Text)
value = <?php echo $_SESSION["namevalue"]; ?> />
This should be:
php Syntax (Toggle Plain Text)
value="<?php echo $_SESSION["namevalue"]; ?>" />
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Agree with Xan's code fix
embedding php inside html, it is important to get all the quotes in.
only add a usefula(maybe) caveat to the code he provided, a recommendation to change whatever editor used to something that code highlights
It becomes easy to see when something is missing if the text is some bright colour when a(the) quote(s) Brace(s) Bracket(s) < > is(are) missing
Notepad++ Notepad2 & a bunch of good code highlighting editors
without the quotes output html for a nul field is
with quotes a nul gives
embedding php inside html, it is important to get all the quotes in.
only add a usefula(maybe) caveat to the code he provided, a recommendation to change whatever editor used to something that code highlights
It becomes easy to see when something is missing if the text is some bright colour when a(the) quote(s) Brace(s) Bracket(s) < > is(are) missing
Notepad++ Notepad2 & a bunch of good code highlighting editors
without the quotes output html for a nul field is
value= /> your visble backslashwith quotes a nul gives
value="" /> Last edited by almostbob; Sep 9th, 2009 at 9:31 pm.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Sep 2009
Posts: 14
Reputation:
Solved Threads: 0
Hey All - Thanks for the several different suggestions. I am using but was able to determin that the previously mentioned part was where I was messing up so hence my limited code post.
I am still getting used to PHP and NetBeans both so the color scheme/code completion and the exact ;,'"` where have you was throwing me off.
Thanks again.!
Andy
PHP Syntax (Toggle Plain Text)
if(isset($_SESSION["namevalue"]))
I am still getting used to PHP and NetBeans both so the color scheme/code completion and the exact ;,'"` where have you was throwing me off.
Thanks again.!
Andy
![]() |
Similar Threads
- Can I capture form input text & pass it to the following page (JavaScript / DHTML / AJAX)
- Capture a form input string (JavaScript / DHTML / AJAX)
- Looking for PHP Web Spider Script (PHP)
- problem with posting a variable (PHP)
- Need Contact Us form using PHP Script (PHP)
- Oracle sql query (Oracle)
- help with this query (PHP)
- php validator (PHP)
Other Threads in the PHP Forum
- Previous Thread: php/mysql search display
- Next Thread: Wampserver and Tomcat Apache ?
Views: 554 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code compression cron curl database date directory display download dropdown dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla limit link login loop mail md5 menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search secure select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video votedown web xml youtube






