php


PHP cURL code 0


Im trying login on https://aulavirtual.cibertec.edu.pe/login/index.php
using cURL but i don't know why the page not connect
POST /login/index.php
https://aulavirtual.cibertec.edu.pe/login/index.php
POST /login/index.php HTTP/1.1
Host: aulavirtual.cibertec.edu.pe
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 43
Referer: https://aulavirtual.cibertec.edu.pe/login/index.php
Cookie: _ga=GA1.3.1291902196.1486689850; _gid=GA1.3.1884694914.1494915834; __tawkuuid=e::aulavirtual.cibertec.edu.pe::wHiJvh0Cg3hTYj3QKz4f6K4WbyFXkEFWMX73qSOlRjJpYoj8t9I9iARBVxBQRnfR::2; Tawk_58a31b6a1919dc09f9ef8f17=vs32.tawk.to::0; MOODLEID1_=%2513%25DFs%25B6%2598%25115%25E5q%259A; MoodleSession=i9jjkvopj6oiobuuk3fet305f6
Connection: keep-alive
Upgrade-Insecure-Requests: 1
username=strusername&password=strpassword: undefined
HTTP/1.1 303 See Other
Date: Tue, 16 May 2017 06:25:26 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.4.45
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: MoodleSession=nqovre7ii6c3m0f6gujlavcl16; path=/
Set-Cookie: MOODLEID1_=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/
Location: https://aulavirtual.cibertec.edu.pe/login/index.php?testsession=20799
Content-Language: es
Content-Length: 510
Keep-Alive: timeout=2, max=1000
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
GET /login/index.php?testsession=20799
https://aulavirtual.cibertec.edu.pe/login/index.php?testsession=20799
GET /login/index.php?testsession=20799 HTTP/1.1
Host: aulavirtual.cibertec.edu.pe
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: https://aulavirtual.cibertec.edu.pe/login/index.php
Cookie: _ga=GA1.3.1291902196.1486689850; _gid=GA1.3.1884694914.1494915834; __tawkuuid=e::aulavirtual.cibertec.edu.pe::wHiJvh0Cg3hTYj3QKz4f6K4WbyFXkEFWMX73qSOlRjJpYoj8t9I9iARBVxBQRnfR::2; Tawk_58a31b6a1919dc09f9ef8f17=vs32.tawk.to::0; MoodleSession=nqovre7ii6c3m0f6gujlavcl16
Connection: keep-alive
Upgrade-Insecure-Requests: 1
HTTP/1.1 303 See Other
Date: Tue, 16 May 2017 06:25:26 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.4.45
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: https://aulavirtual.cibertec.edu.pe/
Content-Language: es
Content-Length: 477
Keep-Alive: timeout=2, max=999
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
login.php
<?php
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$url = 'https://aulavirtual.cibertec.edu.pe/login/index.php';
$post = 'username='.$username.'&password='.$password;
$ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $username.'&'.$password);
curl_setopt($ch, CURLOPT_COOKIEFILE, $username.'&'.$password);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo 'Code: '.$httpcode.'<br/>';
if ($httpcode == 0) {
echo '<h3>Host not found or not is possible do a connection.</h3>';
} elseif ($httpcode == 200) {
echo '<h3>Login Failed.</h3>';
} elseif ($httpcode == 302) {
echo '<h3>Logeed Successful.</h3>';
} elseif ($httpcode == 408) {
echo "<h3>Request Timeout.</h3>";
} else {
echo 'Please send this error to the Admin.';
}
curl_close($ch);
}
?>
so i get code 0

Related Links

Upload PHP Code not uploading image
Why create own request object? [closed]
array declration methods in php [closed]
File extension filter when choosing file to upload
Secure file storage in a server
MySQL: Avoid selecting columns with the same userid
Can't view local images with apache
Bug in Doctrine or am I doing something wrong?
Passing value along with MySQL retrieved value as hidden value in JavaScript to AJAX function
Dynamic forms and PHP
PHP MYSQL Register page Validation
How LOCK works for writing logs into flat file?
PHP mysql how to relationship three tables showing outputs from different tables
Paypal - CURL response is 0 in a new server (connection time out), it's ok in the old server
Using ajax how to get data from the database in PHP?
How to check the exception thrown correctly by PHPUnit?

Categories

HOME
yahoo-weather-api
compilation
hid
code-formatting
braintree
ant
vsts-build
typeerror
amp
drag-and-drop
minecraft
azure-logic-apps
getopenfilename
stimulsoft
pushdown-automaton
sonata
boomi
gmp
coroutine
libgit2
dashdb
coreldraw
backtracking
altium-designer
conda
batch-rename
intel
eclipse-emf
hdmi
marquee
rust-cargo
wampsharp
cucumber-junit
cups
textmate2
uivisualeffectview
variable-variables
swfupload
cloudera-sentry
raytracing
common-table-expression
absolute
axis
liteide
viewmodel
rm
comm
sigsegv
punctuation
exc-bad-access
clrs
network-protocols
word-2016
boost-compute
haraka
google-identity-toolkit
dmarc
nvda
fragmentstatepageradapter
node.js-connect
jeasyui
wif4.5
ambiguity
jnlp
search-form
embeddedwebserver
fuseesb
n-tier-architecture
redpitaya
neo4jphp
sqlbindparameter
preorder
nosql-aggregation
cloo
ctp
stty
void-pointers
bcdedit
ofstream
smartfox
audiotoolbox
thejit
uipangesturerecognizer
space-partitioning
j2mepolish
principles
iphone-sdk-4.3
tacit-programming
accumulator

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App