• 0

Get PHP to submit form info?


Question

9 answers to this question

Recommended Posts

  • 0

Need to break it down. I think there's some confusion here.

Submission of a form is all client side. You either click, or mimic a click with Javascript or vbscript.

You don't want to redirect the browser? Have you just arrived at the page with the querystring?

What you need to do in that case is REQUEST the data from the query string.

If you are at the page, and they have typed the data into a form, and you want to be able submit a form without redirecting. Then you can use javascript to preform and AJAX call.

In this case you still need to build a PHP request page to handle the data in the form submission in the background.

OR....

Explain a little more.

  • 0

<?php
$newvar = file_get_contents("
http://neopets.com/login.phtml?username=BLANK&password=BLANK&destination=neopets.com/stockmarket.phtml?type=portfolio"); echo $newvar;
$html = file_get_contents("http://neopets.com/stockmarket.phtml?type=portfolio");
preg_match("/<marquee>(.*)<\/marquee>/i", $html, $match);
echo $match[0];
?>

That's my current code.

I want the script to login without redirecting, go to the portfolio page and preg_match a marquee there, then echo the preg_match result onto the page the visitor is at.

  • 0
  neoaddict said:

<?php
$newvar = file_get_contents("
http://neopets.com/login.phtml?username=BLANK&password=BLANK&destination=neopets.com/stockmarket.phtml?type=portfolio"); echo $newvar;
$html = file_get_contents("http://neopets.com/stockmarket.phtml?type=portfolio");
preg_match("/<marquee>(.*)<\/marquee>/i", $html, $match);
echo $match[0];
?>

That's my current code.

I want the script to login without redirecting, go to the portfolio page and preg_match a marquee there, then echo the preg_match result onto the page the visitor is at.

I don't think it will work as you will create a new session on the second file_get_contents . and therefore not be logged in.

  • 0

If you don't want to redirect take out the echo $newvar; since this echoes the html and it must have a hidden redirect to their site.

for what you need to do it's somewhat hard you need to use the CURL library of PHP to enter the site and navigate mantaining a user session (inside your php script).

Then get your info a close your session.

It can be done, depends on your PHP skills :yes:

  • 0

<?php

function GetCurlPage ($page) { 
$page = "http://neopets.com/login.phtml?username=TEST&password=TEST&destination=/stockmarket.phtml?type=portfolio";

$ch = curl_init($page);

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

// grab URL and pass it to the browser
$tmp = curl_exec($ch);

// close curl resource, and free up system resources
curl_close($ch);

$tmp = preg_match("/<marquee>(.*)<\/marquee>/i", $tmp, $match);
return $tmp;
echo $match[0];
}

GetCurlPage($page);
?>

That's what I got so far, but it still won't display any matches.

  • 0

Got rid of the return, but the following code won't visit the login URL and won't preg_match, but will visit the stockmarket URL:

<?php
$page = "http://neopets.com/login.phtml?username=neoaddict_account&password=transphamatic1&destination=/stockmarket.phtml";
$ch = curl_init($page);

// set URL and other appropriate options
//curl_setopt($ch, CURLOPT_URL, "http://neopets.com/login.phtml?username=TEST&password=TEST&destination=/stockmarket.phtml");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

echo curl_exec($ch);
$info = curl_getinfo($ch); 
$retrievedhtml = file_get_contents("http://neopets.com/stockmarket.phtml");
if (!preg_match("#<marquee>(.*)<\/marquee>#i", $retrievedhtml, $match)){
echo ":-(";
}
else{
echo $match[0];
}

curl_close($ch);

echo $match[0];
?>

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Get Microsoft Office 2021 Professional for Windows, now only $44.97 by Steven Parker Get all these essential Microsoft apps for your Windows PC Today's highlighted deal comes via our Apps + Software section of the Neowin Deals store, where you can score a lifetime license to Microsoft Office 2021 for Windows for only $44.97 (buying link below). This bundle is for families and small businesses who want classic Office apps and email. It includes Word, Excel, PowerPoint, Outlook, Teams, and OneNote. A one-time purchase installed on 1 Windows PC for use at home or work. Lifetime license for MS Word, Excel, PowerPoint, Outlook, Teams, & OneNote One-time purchase installed on 1 Windows PC for use at home or work Instant Delivery & Download – access your software license keys and download links instantly Free customer service – only the best support! Microsoft Office Professional 2021 (for Windows) includes: Microsoft Office Word Microsoft Office Excel Microsoft Office PowerPoint Microsoft Office Outlook Microsoft Office Teams Microsoft Office OneNote Microsoft Office Publisher Microsoft Office Access No faffing about with subscriptions, just classic apps that don't expire.Good to Know ONE-TIME PURCHASE INSTALLED ON 1 DEVICE Redemption deadline: redeem your code within 30 days of purchase Access options: desktop Full versions No subscriptions – no monthly/annual fees Version: 2021 Updates included A lifetime subscription to Microsoft Office 2021 Professional normally costs $219.99, but this deal can be yours for just $49.97, that's a saving of $180. For full terms, specifications, and license info, click the link below. Use MSO5 coupon for an additional $5 off. Expires June 29. Get Microsoft Office Professional 2021 deal for just $44.97, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • This is a common misnomer that Intel refuses to correct, E-Cores the E doesn't stand for efficiency in power (although they are more efficient than performance cores) but are actually "space efficient" which means they occupy much less space for same computational power thus allowing more of them in a footprint.
    • If you have top secret documents from the government or your company, you will not use a user cloud service. Pete Hegseth would like a word. I doubt that security fiasco stops at Signal. Stop being so stupid that you think that your useless information on your PC is as important as you think it is. This is just another crude way of saying it shouldn't matter if have nothing to hide. Not everyone wants to become a product, but you do you. If you cared about the content, you would not use these documents and photos on Android and iPhone phones because the telemetry there is 100,000% worse than on Windows 11. I love the telemetry comment. You cannot prove one way or another if it's better or worse on Windows vs. iOS or Android.
  • Recent Achievements

    • Reacting Well
      Cole Multipass earned a badge
      Reacting Well
    • Reacting Well
      JLP earned a badge
      Reacting Well
    • Week One Done
      Rhydderch earned a badge
      Week One Done
    • Experienced
      dismuter went up a rank
      Experienced
    • One Month Later
      mevinyavin earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      693
    2. 2
      ATLien_0
      273
    3. 3
      Michael Scrip
      218
    4. 4
      +FloatingFatMan
      188
    5. 5
      Steven P.
      146
  • Tell a friend

    Love Neowin? Tell a friend!