473,656 Members | 2,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to use htmlspecialchar s in the form - help

Newbie question I guess. Please show me how to use the htmlspecialchar s
function in the form below, Thanks:

<form action="formtes t1.php?c=1" method=POST>
<b>Find Results with:
These words: <input type="text" length=40 name="keywords" >
input type="submit" value="Search">
</form>

Jul 17 '05 #1
1 4229
.oO(leegold2)
Newbie question I guess. Please show me how to use the htmlspecialchar s
function in the form below, Thanks:
You only need it when you print out the previously entered informations
again, which is not the case with your form (no default value for the
input field).

Usually the code would look like this:

<input name="foo" value="<?php print htmlspecialchar s($foo)?>">

where $foo contains the value that was entered in the text field before.
<form action="formtes t1.php?c=1" method=POST>
<b>Find Results with:
These words: <input type="text" length=40 name="keywords" >
input type="submit" value="Search">
</form>


You could also try this:

<form action="formtes t1.php?c=1" method="post">
<label for="keywords"> Find results with these words:</label>
<input name="keywords" id="keywords" length="40">
<input type="submit" value="Search">
</form>

Labels make forms more accessible, especially when used for checkboxes
and radio buttons.

Micha
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8031
by: Phil Powell | last post by:
If $val is the following: ....Just revamped the site's Content Management Application I built.. so do bear in mind.. sorry! Phil stripslashes(htmlspecialchars($val)) should produce the following, or so I thought:
3
2324
by: SoulSniper | last post by:
I'm working on a modification to a popular blog script, the modification is for putting source code into a post for the world to see. The idea is exactly the same as putting code into a post on a phpBB2 forum. When posting code it has to be between and . The text ends up in a nice looking table making for easy reading. The problem I have is that I want the text between and to have htmlspecialchars() run on it before it is returned,...
1
2265
by: brianj | last post by:
Running php 4.3.6 on winxp machine I have following code: ----------------------------------------------------------------------- Restaurants <select size='1' name='restaurants'> <? while ( $row = mysql_fetch_array($restaurant)){ $opt = "<option value = '" . $row . "'>" . $row . "</option>"; $opt = htmlspecialchars($opt, ENT_QUOTES);
2
1856
by: universalbitmapper | last post by:
Hi, $new = htmlspecialchars("<a href=", ENT_QUOTES, 'ISO-8859-15'); echo $new; displays: <a href Instead of :
1
2129
by: Software Engineer | last post by:
Testing htmlspecialchars() PHP Function - Converting HTML Characters http://sqa.fyicenter.com/Online_Test_Tools/Test_htmlspecialchars_PHP_Function.php When data needs to be presented in Web pages, HTML special characters must be well protected Otherwise, data well not be presented properly, or the Web will become corrupted. This page allows you to learn and test the htmlspecialchars() function to protect embedded data in Web pages.
3
2905
by: DavidPr | last post by:
I have this when posting to a database: $a = htmlspecialchars($_POST); $a = addslashes($a); I have this when displaying the data on a Web page: $article=nl2br(stripslashes(mysql_result($result,$i,"article"))); The stripslashes works, but the html characters show up, i.e. < >, etc. htmlspecialchars going into the database is good, but how do I reverse it to display in a Web page?
3
3231
by: DavidPr | last post by:
I'm using this: <?php if (isset($_POST)) { $city = htmlspecialchars($_POST); if (!get_magic_quotes_gpc()) { $city = addslashes($city);
14
9492
by: Jeigh | last post by:
Hello, I've created a form where users of my site can contact each other, when I'm processing the data I use: $message = nl2br(htmlspecialchars($_POST)); For example.
8
7910
by: mijn naam | last post by:
Can someone please explain to me why/when one would use htmlspecialchars instead of htmlentities? I know: if you only want to get certain characters translated. This is not the answer I'm looking for, I would like to know *why* you would want that, as opposed to a full translation.
0
8382
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.