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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:47:13+00:00 2026-06-03T18:47:13+00:00

I have a script on my webserver that initiates a HTTPS connection with a

  • 0

I have a script on my webserver that initiates a HTTPS connection with a secured payment solution. The payment solution allows the user to store its credit cards credentials, so the script’s integrity is mandatory.

The script is called from web and from a web browser launch by an iPhone application.
It takes several POST values in entry:

  • user ID
  • value
  • currency
    … etc

to generate the initial request with the payment solution.

My goal is to secure, as much as possible, the POST values sent to the script to avoid attacks, essentialy because anyone could see the POST variables it takes in entry with a simple Firebug.

The script is reached via HTTPS protocol, and this is what I came up with in order to secure the content data :

if (!empty($_POST)) {

    $uid = $_POST['uid'];
    $nonce = $_POST['nonce'];
    $request_timestamp = $_POST['time'];

    //other useful values ...
}

/*
 * Test 1 : is the nonce correct ? (Example of possible hash)
 */
if (strcmp(md5($uid . $request_timestamp . 'mygrE4TpassPhraZ'), $nonce) !== 0) {
    echo 'Bad nonce';
    exit;
}

/*
 * Test 2 : is the timestamp value acceptable ? 10 seconds maximum here.
 */
if (time() - $request_timestamp > 10) {
    echo 'Request too old';
    exit;
}

/*
 * Test 3 : is this request is the first valid one that I receive with those credentials for this user ?
 */
if (strcmp(User::getOnGoingNonce($uid), $nonce) === 0) {
    echo 'Request already registered';
    exit;
}

//direct database access
User::setOnGoingNonce($uid,$nonce);

/*
 * Finally, chat granted with the payment solution ...
 */

Do you think this is secure enough ? Do you have cleaner solutions ?

Inputs would be greatly appreciated, thank you in advance.

  • 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-03T18:47:14+00:00Added an answer on June 3, 2026 at 6:47 pm

    It is good developer practice to sanitize and filter every user input. There is a special PHP function for that purpose, available to make a programmer’s life easier. It is called filter_var().
    If you work with arrays you can use the filter_var_array().
    See here for details.

    So, the practical solution to your code should be something like this:

    $uid = filter_var($_POST['uid'], FILTER_SANITIZE_NUMBER_INT);
    $nonce = filter_var($_POST['nonce'], FILTER_SANITIZE_STRING);
    $request_timestamp = filter_var($_POST['time'], FILTER_SANITIZE_STRING);
    

    I assume, that ‘uid’ is a integer, other variables are strings. But you can choose whatever filter you need. See here for type of filters.

    When sanitizing the user input you ensure, that your script will not allow SQL injection attacks, for example, or XSS attacks.

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

Sidebar

Related Questions

On a webserver, I have a php script that parses a .sql file (which
I have an upload script that runs on a windows webserver 2008. The uploads
I have a webcam script that sends a JPG via FTP to my webserver
I have script which allows to display Bing search results. I can call for
I have some script in my default page that redirects users to language specific
I have a script that checks something on my PC every 5 minutes and
I have a script that connects to SQL Server 2005 default instance. But I'm
I have a script that will convert a text file into a resource file,
I have a script that generates DDL scripts to define materialized views for a
I have a script that is very long to execute, so when i run

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.