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

PHP: double output of php errors / warnings / notices
User input dependent table
AJAX creates a new session everytime
PHP sort merged array by id from 1st array then 2nd array and repeat
Graph API post status not link
JSON file_get_contents is not working small example included
need to add posts per page to custom template in wordpress
PHP Replace part of string when
Unable to save image paths to database yii
updating array in php
How to get each parent page, and display its children as separate divs in Wordpress
How to get all categories and subcategories name in Virtuemart
can't read the first row from my database using mysql and php
PHP file search lists directory as file
How to call data from HTML to PHP
HTTP REFERER isn't set

Categories

HOME
php
cocoapods
visual-studio
memory
tomcat
apple-push-notifications
selenium-builder
message-queue
out-of-memory
biztalk
lvm
ag-grid
jpa-criteria
hspi
reportviewer
azure-graph-api
migrate
erd
chromecast
business-intelligence
jquery-file-upload
mpu6050
powermock
sql-injection
orange-api
jaspersoft-studio
renderscript
spam
kamailio
acl
php-5.3
bonita
quick-nimble
reporting
kendo-listview
adminer
java-stream
express-session
numerics
unification
ejml
virtual-memory
doctrine-extensions
common-table-expression
extjs4.1
exc-bad-access
freshdesk
pen
kendo-editor
alertify
prefetch
maatwebsite-excel
yui3
jsonix
jpda
dmarc
wininet
seccomp
coovachilli
piping
perforce-integrate
node-glob
facebook-ios-sdk
polymerfire
gwt-syncproxy
grinder
deeplink
apache-commons-digester
canopy
wso2ml
espresso
supersocket.net
uitest
wicked-gem
rfc5545
tkx
uno
rubber
berkeley-db-xml
code-complexity
typesafe-stack
principalcontext
django-facebook
ax
.net-remoting
examine
email-verification
xalan
gitx
image-formats
cakeyframeanimation
prototypal-inheritance
django-apps
kernel32
tablet-pc
asp.net-mvc-views
nsconnection
channelfactory
mygeneration
aggregator
tessellation
android-input-method
asdoc
oracle-pro-c
google-translator-toolkit
accumulator
remote-working
webclient.uploaddata

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