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 6115149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:03:27+00:00 2026-05-23T15:03:27+00:00

I have a form which I submit and I use .serialize to help me

  • 0

I have a form which I submit and I use .serialize to help me gather all data from the form. Now, I’ve checked in firebug what is sent in POST and I can see a nice formated string like example

index.php?data=sth&data2=sth

but the problem is with this & in the PHP – the PHP outputs it like this:

index.php?data=sth& a m p ;data2=sth

See this amp? Well it is written without spaces and it’s and encoded (as I found out in google) version of &. So, what should I do to input this url correctly in the database and then fetch it a nd show it on the site without this & amp; ?

edit: if it’s possible I would like a string with that & to be put in that format to DB. (so, with & sign).

edit#2:
how I send data:

 var formData = $("#myForm :input[value]").serialize();
 $.ajax({
     type: 'POST',                    
     cache:false,
     url: '_ajax/updateGameInfo.php', 
     async: false,                     
     dataType: 'text',
     data: allData,
     success: function(jsonObj) { 
         if (jsonObj){                       
             $msg = 'Data sucessfully updated! Reloading page...';
             alert($msg);
         }
         else{
             $msg = 'Error with the update!';
             alert($msg);
         }   
     }
 });    

And here is my updateGameInfo.php:

$gameRepos = new GameRepository();    

$game = $gameRepos->updateGame();
echo json_encode( $game );   

And if you also like, here is my updateGame function from GameRepository:

public function updateGame()
{
    $cleanPost = array_map( array('GameRepository', 'cleanPostData'), $_POST);
    $attributes = array_keys($cleanPost);
    $values = array_values($cleanPost);      

    $table = $this->resolveTableName( $cleanPost["selectedTypeId"] );
    $id = $cleanPost["selectedGameId"];

    if ($this->openConnection())
    {                                                
        $pairs = "";
        foreach ($cleanPost as $attribute => $value){
            if ($attribute != "selectedGameId" && $attribute != "selectedTypeId"){

            if ($attribute == "url")
                $value = str_replace("amp;", "", $value);    

                $pairs .= $attribute . "='" . $value . "',";
            }    
        }

        $pairs = rtrim($pairs, ','); //remove last comma

        $query = "UPDATE $table SET $pairs WHERE id=$id;";

        $result = pg_query($query);
        if (!$result){
            mysql_error());
            return false;
        }                
        else 
            return true;
    }
    else
        return false;
}
  • 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-05-23T15:03:28+00:00Added an answer on May 23, 2026 at 3:03 pm

    If you are passing in the URL as a POST variable, then PHP is going to automatically encode any special characters. So, assuming the POST variable name is url, you would want to do this in your php script before everything else:

    $_POST['page_url'] = htmlspecialchars_decode($_POST['page_url']);
    

    The issue isn’t with jquery, it’s with php. You’ll run into similar issues when passing json strings.

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

Sidebar

Related Questions

I have a form which takes multiple inputs from user. Now I wanna show
I have one form which need to submit data into two different tables in
I have a basic html form which I want to use with two submit
I have a form which on submit I want to run a script via
I have a form which users must fill out and submit. The controller action
I have a form which I want to submit upon button click which is
I have a asp.net web form which will submit information to come as emails.
I have a form which encapsulates all the functionality, but works with a concrete
I have a form on which I use validation. This form has a section
I have a simple form which is inside IFRAME. When user click on SUBMIT,

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.