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

  • Home
  • SEARCH
  • 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 7816161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:45:58+00:00 2026-06-02T05:45:58+00:00

Possible Duplicate: AJAX only access So I have these javascript functions I run depending

  • 0

Possible Duplicate:
AJAX only access

So I have these javascript functions I run depending on who won a contest.

function winA() 
{
var x = "<?php echo $id;?>"
$.ajax({ url: 'win.php' ,
         data: { id: x }
   }); 
}

function winB() 
{
var val = "<?php echo $i;?>"
$.ajax({ url: 'win.php' ,
         data: { id: val }
   }); 
}

The file win.php updates a MySQL with who won. What troubles me is if someone simply goes to

http://mysite.com/win.php?id=1

and refreshes it a whole lot of times I clearly will have some incorrect results on the MySQL server.

I am wondering exactly how one would make it so that URL could only be accessed when appropriate, via this ajax call. Alternatively make it so the win.php file only to actually execute when it has ‘authorization’ that expires after loading the php file.

Thanks in advance, Aaron.

  • 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-02T05:46:00+00:00Added an answer on June 2, 2026 at 5:46 am

    You could use a session, expanding from my comment:

    Main game page

    <?php
    session_start();
    
    //Do game....
    
    //Decide Winner
    
    $_SESSION['winner']='A'; //or B depending on who won
    
    ?>
    

    Then an AJAX request with blank params ect, just so won.php gets touched

    function win(){
      $.ajax({
        url: "win.php",
        cache: false
      }).done(function(html){
       //Dont do anything or you could get a response from the won.php request an update something
      });
     }
    

    Win.php

    <?php
    session_start();
    
    if(isset($_SESSION['winner'])){
        $winner=$_SESSION['winner'];
        //Do update ect
    
        //Unset Winner session var, by unsetting the user would need to play the game again to get it set
        unset($_SESSION['winner']);
    }else{
        header('Location: ./index.php');
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Prevent Direct Access To File Called By ajax Function I'm creating a
Possible Duplicate: jQuery: Return data after ajax call success I have the following function
Possible Duplicate: How to: Back button support “Ajax” I have a ASP.NET MVC implementation
Possible Duplicate: jquery/ajax load new content when available i have a table named news
Possible Duplicate: jQuery: How to stop AJAX function escaping JSON string used to POST
Possible Duplicate: Why is this function returning “undefined”? Let's assume I have the following
Possible Duplicate: Multiple ajax calls inside a each() function.. then do something once ALL
Possible Duplicate: Kill Ajax requests using JavaScript using jQuery Here is the simple code
Possible Duplicate: E-mail validation in php? please help I have Ajax sign up form.
Possible Duplicate: Ajax, javascript send variable to another page, on click Hello, Lets say

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.