-4

hi
i'm new to php but i tried to make my own edu website but i'm facing lot of problem to fetch the result using php
external site is about one of the Engineering university where 10k students result will be displayed by this website bcoz of this its server will be busy.so i tried to fetch the result from it.
coming to reqirement
when the students enter their usn no(eg:1db11cs001) when user hit submit button it must fetch result from external website(eg:http://results.vtu.ac.in/vitavi.php) and it must display result on my website
so plz help me by giving complete code
for more details and code
plz follow the link
http://stackoverflow.com/questions/13899643/to-fetch-the-form-results-from-an-external-website-on-the-same-page
coming to problem topic
when the student enter thier usn no/roll no(eg:1db13cs005) its just showing the student name but i need the complete result copy to be displayed on my website

3
Contributors
19
Replies
104
Views
3 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1
    diafol 3,720   3 Years Ago

    OK, well that's an issue for you. But be aware just because somnebody else if ripping off data, doesn't mean it's open season for everybody else. Equally, that site may have an agreement with the uni. Storing data in a db may be a bit dodgy - especially as you … Read More

  • 1
    diafol 3,720   3 Years Ago

    If you store data, you can output it any way you want, BUT are you **allowed** to do so? You could split the id with preg_* functions: integer|short alpha (2 chars?)|integer|short alpha (2 chars?)|intger OK, I think I've made it quite clear by now that you need to check if … Read More

  • 2
    diafol 3,720   3 Years Ago

    That's up to you mate. But don't ask me, ask the uni. Good luck with it, over and out. Read More

0

First of all, make sure you're not falling foul of the university/college by doing this. If it's OK, then I'm assuming that you need to use cURL to scrape the page unless they have an API which could allow you to once again use cURL or file_get_contents or even use js to get json data.

<form name="new" action="vitavi.php" method="POST">
 <p>Enter the University Seat No: <input type="TEXT" name="rid" size="20" maxlength="50"><br><br><br><br>
 <input type="SUBMIT" name="submit" value="SUBMIT" align="center"><br></p>
<form>

So it seems that if you were to use cURL for instance, you'd want to pass the POST "new", "rid" and "submit"

You may wonder about the need to pass "submit", but it may be part of validating whether the form had been submitted, e.g.

if(isset($_POST['submit']))

So you'd set the cURL to look at http://results.vtu.ac.in/vitavi.php

Edited by diafol

-3

i'm gettin 404 error to the below code can u solve this problem

<?php

echo '<form name="new" action="vitavi.php" method="POST">
 <p>Enter the University Seat No: <input type="TEXT" name="rid" size="20" maxlength="50"><br><br><br><br>
 <input type="SUBMIT" name="submit" value="SUBMIT" align="center"><br></p>
<form>';

if(isset($_POST['submit'])&&(!empty($_POST['rid'])))
{
    $location = 'http://results.vtu.ac.in/vitavi.php';

    $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $location );

    $post_array = array(
        "rid" => $_POST['rid'],
        "submit" => "submit"
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch);

    $start = '<TD width="513">';
    $end = '<br>';

    $response = strstr($response, $start);
    $end = stripos($response, $end);
    $response = substr($response, strlen($start), $end - strlen($start));

    echo $response."<br/>";
}  

?>

Edited by punith_1

0

@diafol
i've tried my level to clear my error but i couldn't fix it so help me out

0

but to the above code it is fetching student name but i need to fetch complete exam result sheet from external website
plz can anyone solve this

0

The html is wrong in my original - the close form tag should be:

</form>

Also the action shouldn't be "vitavi.php" unless you have a page called that on your site.

0
if(isset($_POST['submit']) && isset($_POST['rid']) && !empty($_POST['rid']))
{
    $location = 'http://results.vtu.ac.in/vitavi.php';
    $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $location );
    $post_array = array(
        "rid" => $_POST['rid'],
        "submit" => "SUBMIT"
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch);
    $start = '<TD width="513">';
    $end = '<br>';
    $response = strstr($response, $start);
    $end = stripos($response, $end);
    $response = substr($response, strlen($start), $end - strlen($start));
    echo $response."<br/>";
}  
?>

<html>
<form name="new" method="POST">
 <p>Enter the University Seat No: <input type="TEXT" name="rid" size="20" maxlength="50"><br><br><br><br>
 <input type="SUBMIT" name="submit" value="SUBMIT" align="center"><br></p>
</form>
</html>

Works for me (name and id)

-3

@diafol
for the above code its just accessing only student name and id but i need to fetch complete result as shown below 7e6294b1d2f0140535ac6b2835c96c52

Edited by punith_1

0

i just test above code after response print it working.
$response = curl_exec($ch);
print_r($response);
exit;

0

The reason you only get the name is because you place a stop at '<br>'. Unfortunately the underlying html for the table is a total mess. Many nested tables. A way around this may be to use an xmlparser, but in order to use these, the xml/html needs to be well formed and I'm not sure this page has well-formed html. If you can find any hooks e.g. classes or attributes then setting multiple start and end points may be possible.

THis works to output the table...

$response = curl_exec($ch);

//change this to whatever...
$extract = array("start" =>'<TD width="513">', "end"=>'<b>REGISTRAR(EVALUATION)</b>');

$start = stripos($response, $extract['start']);
$end = stripos($response, $extract['end']);
$response = substr($response, $start, $end);

echo $response."<br/>";

BUT, as I mentioned, the html will not be well formed, you'll probablt need to add various open and close tags to the response to make it well formed on your page.

Edited by diafol

0

@diafol
personally i thank u.for giving code its perfectly working.

0

@mangel_murti
thank u for solving problem .its working fine

0

when they announce the result in VTU can i store all students exam result in my database from external site(vtu) before/while displaying students result

0

when they announce the result in VTU can i store all students exam result in my database from external site(vtu) before/while displaying students result

Ensure that you have permission to do this. I assume that this is confidential information. Have students given you permission to access their data? Is the uni/college aware that you are scraping their site for data? These should be concerns that you should address. Pleading ignorance will not help in the event of complaints being made. As the college/uni are responsible for keeping students' results saf, so will you (if you get permission in the first place, that is).

0

@diafol
i'm nt sure of storing result but in our uni website the previous year results are not display but in other website like Click Here.com,Click Here... they r able to show result from this i think they r storing results in their database

Edited by punith_1

1

OK, well that's an issue for you. But be aware just because somnebody else if ripping off data, doesn't mean it's open season for everybody else. Equally, that site may have an agreement with the uni.

Storing data in a db may be a bit dodgy - especially as you may at a later date, just scrape, store and deliver the stored data. That would not then take into account any ammendments to the original data.

What would be really useful is if the uni had an api that allowed "key holders" to access the data.

-1

@diafol
for more info abt external site(vtu) follow this link Click Here
without storing result in my db can i make rank list according to class student marks (ascending order)
firstly i will give info of our id(1db12cs005
in this 1 is indicated for bangalore region,"db" stands for college code,"12" stands for which sem we r studing right now,"cs" stands for computer science course,"005" is our reg no)
i want to make class rank for eg for cs course itself
this type of detail i hv seen in vtualerts so can u help me out

Edited by punith_1

1

If you store data, you can output it any way you want, BUT are you allowed to do so?

You could split the id with preg_* functions:

integer|short alpha (2 chars?)|integer|short alpha (2 chars?)|intger

OK, I think I've made it quite clear by now that you need to check if you need permission to store this data. Personally I would not store this data without contacting the uni. As a student, I would be very concerned that anybody could access my private data. For instance, do I want you to rip off my results and then rank them compared to everybody else? I don't think I would.

Edited by diafol

0

ok
can i give a download link of result to a student below their result sheet

2

That's up to you mate. But don't ask me, ask the uni. Good luck with it, over and out.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.