If you’re looking to post data to a URL from PHP code itself (without using an html form) it can be done with curl. It will look like this:
$url = 'http://www.someurl.com'; $myvars = 'myvar1=' . $myvar1 . '&myvar2=' . $myvar2; $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_POST, 1); curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt( $ch, CURLOPT_HEADER, 0); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec( $ch );
This will send the post variables to the specified url, and what the page returns will be in $response
Related Posts:
- How to prevent the “Confirm Form Resubmission” dialog?
- Difference between “as $key => $value” and “as $value” in PHP foreach
- What is a slug?
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- How to fix “Headers already sent” error in PHP
- How to fix “Headers already sent” error in PHP
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- Mysql query- How to use contains?
- S_SESSION variable (user role) not recognised
- What are the main differences between PHPExcel and PhpSpreadsheet?
- How to force file download with PHP
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- How to check if a string starts with a specified string?
- XAMPP Port 80 in use by “Unable to open process” with PID 4
- How to replace “if” statement with a ternary operator ( ? : )?
- phpMyAdmin: secret passphrase?
- Elegant way to search for UTF-8 files with BOM?
- Email Not Sending from Byethost Hosting
- laravel updateOrCreate method
- what does a .php?id=&value=value means?
- Get Current URL in Magento and show something
- Deleting an element from an array in PHP
- Error 330 (net::ERR_CONTENT_DECODING_FAILED):
- How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
- Call to undefined function curl_init().?
- Weird PHP error: ‘Can’t use function return value in write context’
- How do you parse and process HTML/XML in PHP?
- How to verify password against database?
- Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)
- Difference between $_SERVER[‘DOCUMENT_ROOT’] and $_SERVER[‘HTTP_HOST’]
- Call to undefined function mysql_query() with Login
- Is there a difference between the UTC and Etc/UTC time zones?
- PHP mail not working for some reason
- PHP mail not working for some reason
- Multi-line strings in PHP
- Commands out of sync; you can’t run this command now
- Refresh a page using PHP
- Call to undefined method mysqli_stmt::get_result
- cURL error 60: SSL certificate: unable to get local issuer certificate
- Are PDO prepared statements sufficient to prevent SQL injection?
- How to create cron job using PHP?
- How do I expire a PHP session after 30 minutes?
- retrieve data from db and display it in table in php .. see this code whats wrong with it?
- WordPress Error : Upload folder is not writable. Export and file upload features will not be functional
- How can I do ‘insert if not exists’ in MySQL?
- Count how many files in directory PHP
- Can’t use method return value in write context
- PHP get domain name
- mysql_field_name to the new mysqli
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli::query(): Couldn’t fetch mysqli
- Php include not working? function not being included
- php foreach with multidimensional array
- Creating a php search bar
- header location not working in my php code
- NotFoundHttpException in RouteCollection.php line 161: in laravel 5
- PHP reindex array?
- Only variable references should be returned by reference – Codeigniter
- How to fix the session_register() deprecated issue?
- file_put_contents: Failed to open stream, no such file or directory
- What does MYSQLI_NUM mean and do?
- How to convert string to boolean php
- PHP json_decode() returns NULL with valid JSON?
- Are There Any Cron Jobs Alternative?
- How to remove unused dependencies from composer?
- How to Create Multiple Where Clause Query Using Laravel Eloquent?
- Laravel 5 Clear Views Cache
- What is ?
- How to import csv file in PHP?
- * failed to open vchiq instance
- Undefined variable: $_SESSION
- How can I fetch all items from a DynamoDB table without specifying the primary key?
- Error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- How to convert array to SimpleXML
- How can I find the php.ini file used by the command line?
- Check if URL has certain string with PHP
- Check if a PHP cookie exists and if not set its value
- Notice: Undefined offset: 0 in
- How to Sort a Multi-dimensional Array by Value
- PHP array printing using a loop
- Download files from server php
- Call PHP function from jQuery?
- Facebook – Error parsing input URL, no data was cached, or no data was scraped
- Is there any way to test PHP locally without installing a server?
- PHP – syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
- what is $_SERVER[‘QUERY_STRING’] ? how it works?
- Getting the screen resolution using PHP
- Insert string at specified position
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- How can I force users to access my page over HTTPS instead of HTTP?
- JavaScript equivalent of PHP’s in_array()
- Create a folder if it doesn’t already exist
- Implement linked list in php
- How to remove index.php from WordPress site URL
- Logout button php
- Unset cookies php
- PHP Like thing similar to MySQL Like, for if statement?
- How get value from URL
- WordPress visual composer not loading
- PHP & Case Sensitivity