• 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

    • https://youtu.be/QvsuYWvtlmw?t=46
    • Teams immersive sounds like a really fun 3D experience by Usama Jawad Microsoft Teams is heavily used in enterprise environments, especially where customers are well entrenched in Redmond's ecosystem. As such, it is imperative for Microsoft to regularly add new features to Teams to retain its existing customers while also attracting new ones. Now, the firm has announced immersive 3D virtual events for the communication and collaboration software. Teams immersive is basically a custom 3D environment that enables attendees and organizers to interact with each other in a more natural way. Managing and planning an immersive event is as easy as scheduling a regular Teams meeting as you can do so directly via the Teams calendar UX. The process to set up Teams immersive appears to be quite intuitive and, well, fun. You can add 3D models, logos, images, text, and video to the environment to customize it according to your preferences using the Editor utility, without knowing any coding language. But if that sounds too hectic, you can also leverage the existing templates from Microsoft. Teams immersive aims to make virtual events more interacting and engaging. Organizers can shine a spotlight on their avatar when they start an event, bring virtual attendees to the stage during the Q&A session, find a specific attendee, and see the crowd's reactions as you move between rooms like an actual host. Teams immersive also empowers more natural experiences through spatial audio, with people also having the ability to listen to someone better by just moving closer to them virtually. This could be very useful in large events, for example, virtual conferences or an all-hands meeting hosted in 3D on Teams. That said, it is important to note that Teams immersive is currently in public preview and requires the rather expensive Teams Premium add-on license, which costs a hefty $10 per user per month for an organization.
  • Recent Achievements

    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
    • First Post
      Doreen768 earned a badge
      First Post
    • One Month Later
      James_kobe earned a badge
      One Month Later
    • Week One Done
      James_kobe earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      656
    2. 2
      ATLien_0
      254
    3. 3
      Xenon
      167
    4. 4
      neufuse
      146
    5. 5
      +FloatingFatMan
      121
  • Tell a friend

    Love Neowin? Tell a friend!