troubleshooting Question

How do I create a Silent POST within a Silent POST to automatically login (1st POST) and then change a variable (2nd POST)?

Avatar of NeedExpertHelp
NeedExpertHelp asked on
PHP
3 Comments1 Solution524 ViewsLast Modified:
Hi,

I want to create a PHP script that automatically logs in to a site and then automatically changes the e-mail address for that account.  I found a "Silent POST" curl script (attached) that works for the first part and I am able to log in successfully.  But how do I change the e-mail variable once logged in?

To log-in, I do the first "Silent POST" (attached).  But how do I do a second "Silent POST" to change the e-mail of the account once the server script is logged-in (the form name of the e-mail field once logged in is "newemail" so the CURLOPT_POSTFIELDS variable would simply be "newemail=$newemail")?

I have tried repeating the same code attached (with the new variables) after the login code and it did not work even though it logs-in successfully.

Any help would be appreciated.  Please provide the exact working code if possible.

Many thanks.  
<?php
    $username="username";
    $password="password";
 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,"http://www.server.com/login.php");
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "username=$username&password=$password");
 
    curl_exec ($curl);
 
    curl_close ($curl);
?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros