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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:29:58+00:00 2026-05-16T20:29:58+00:00

Alright so I want my users to be able to click a link that

  • 0

Alright so I want my users to be able to click a link that will allow them to add a movie to their favourite.

So in example I have http://xxx.com/favorite.php?userid=1&movieid=1020

For the moment all works well, it adds the values into database, but since it’s movies, I do not wish the page to reload, hence the use of Ajax which I am new to.

I worked a little bit around with the different ways of doing it, but never succeeded.

I got alot of help earlier on with my PHP issue, and that would be awesome if it could be the same now!

Basicly just click the favorite image (which is a link) and when the action of posting to database is done, well show another image.

Well I tried many ways, including the JSON ones, but I know GET method can be vulnerable, but it uses session + more security so I’m pretty sure it safe for the moment, I can always work on that later.

Although I’d like to know a nice way with a good example, because I still didn’t figured it out.

Thanks to answers tho! Appreciated.

Edit:

Or if not, what would be the best way to POST the info it that’s easier? Best way I found is get, since I’m not that advanced in AJAX / etc

Also in my favorite.php file, the information are being submitted to the server, that is the whole point.

  • 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-16T20:29:59+00:00Added an answer on May 16, 2026 at 8:29 pm

    You need to get JQuery and install it in your web app (see their getting started docs). In your HTML you’ll have:

    <div id="fav_12_345"><a href="javascript:void(null)" id="addfav">Favorite</a>
    

    And in your javascript:

    $("a#addfav").onclick(function(ev) {
        data_id = $(ev).parent.id();
        $.post('someurl', { data_id: data_id }, function(res) {
            // this bit gets run once the call has been processed on the server
            if (res) {
                // update the new image
                $("img#blah").attr("src", 'someurl');
            }
           }, 'json');
     });
    

    And in your PHP

    $data_id = your_sanitise_user_input($_REQUEST['data_id']);
    $data = explode('_', $data_id);
    $sql = "UPDATE table set fav_id=$data[1] where id=$data[0]";
    $res = your_sql_lib_thing($sql);
    print "{res: '$res'}";
    

    All this code is approximate and syntactically flawed probably but gives you the general idea.

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

Sidebar

Related Questions

Alright, so I want the user to be able to enter every character from
Alright so i need to open a .txt file that will be created in
I want to allow users as well as me(the admin) to delete data in
Alright, so I have a button that when clicked, will change the class of
I would like the users be able to create their accounts (which stores the
Alright heres the deal. I have a sports app that i want to update
I have an account management page that will let users change information about themselves.
Alright, here goes. I'm making a very basic app, and I want the user
Alright so in Java I want to ask the user for a time in
Alright so I'm working on a project where I want the app to check

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.