Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:42:27+00:00 2026-06-06T19:42:27+00:00

Do i use htmlspecialchars on $_GET[‘search’] on page2? Wouldn’t i have to remove the

  • 0

Do i use htmlspecialchars on $_GET['search'] on page2? Wouldn’t i have to remove the htmlspecialchars from $_GET['search'] on page3 before i add mysql_real_escape_string to the variable? If so.. how do i remove htmlspecialchars?

page1

 $searchterm = "test"; //users search term
echo "<a href='page2?seach=test'>test</test>";

page2

$var = htmlspecialchars($_GET['search']);
<form action='page3' method='post'><input type='text' name='test' value='$var' /><input type='submit' value='submit'/></form>

page3

$search = mysql_real_escape_string($_POST['test']);
//insert into mysql database
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:42:28+00:00Added an answer on June 6, 2026 at 7:42 pm

    Do i use htmlspecialchars on $_GET['search'] on page2?

    You use htmlspecialchars when you have some text and are about to output it as HTML.

    That is what you are doing in your second example, so yes, you would.

    Wouldn’t i have to remove the htmlspecialchars from $_GET['search'] on page3

    No. The HTML is parsed by the browser to produce a text value.

    (This also means that browsers do not submit HTML-safe data, so when you take the data out of the database then you would use htmlspecialchars before outputting it to an HTML document).

    before i add mysql_real_escape_string to the variable

    Don’t use mysql_real_escape_string, use prepared statements and parameterized queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PHP to filter inputs data I use functions htmlspecialchars and mysql_real_escape_string. Is there
I use htmlspecialchars function in my string. But, I don't want to clean them;
So, preventing website from XSS attack is very simple, you just need to use
if(get_magic_quotes_gpc()) { $location_name = trim(mysql_real_escape_string(trim(stripslashes($_GET['location_name'])))); } else { $location_name = trim(mysql_real_escape_string(trim($_GET['location_name']))); } That's the
In PHP it's possible to have arrays in $_GET , $_POST , $_COOKIE ,
I would like to be sure, that I didn't use $_POST or $_GET in
My friend and I have a pari for beer. From wikipedia: Requiring a secret,
What's better for making links, stripslashes_deep or htmlspecialchars? For example, if I have to
<?php $id = intval($_GET['id']); $sql = mysql_query(SELECT username FROM users WHERE id = $id);
I'm trying to use the Macromedia XSLTransform class to convert XML returned from Amazon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.