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

JetBrains PhpStorm Not Resolving Server Variable?
couldn't fetch session value to another page
Edit YAML array with php Symfony2.8
preg_replace and hidden chars or hidden encoding
BelongsToMany with BelongsToMany relation [closed]
What is equivalent of strtotime in SQL?
Expecting statement after if
Extract array from inside array
How to group from MySQLi using PHP
How to file_get_contents from HTTPS with basic authentication?
WordPress custom taxonomy query
Server Concurrency with High CPU Load
Localhost and 127.0.0.1 show different content in web browser
wordpress - Injecting script with wp_head testing if already exit
Why am I getting error class ImagePixel not found?
PrestaShop AdminController - is there better way to preserve backslashes and html entites?

Categories

HOME
events
class
openxml
mousemove
haproxy
nsview
ant
malware
web2py
iptables
drag-and-drop
ui-automation
cdi
angular2-template
siesta
chromecast
powermock
trace32
fosuserbundle
adobe-illustrator
spring-shell
spring-ldap
qa
amazon-sns
ava
eclipse-emf
nurbs
raima
multi-dimensional-scaling
tsung
audit
toad
winsock
om-next
ms-media-foundation
wdk
subclassing
assertions
xvfb
code-rally
selenide
slideshow
hdiv
haar-classifier
apache-toree
oracle-bmcs
common-table-expression
viewmodel
cyanogenmod
hibernate-ogm
maven-jaxb2-plugin
glimpse
sesame
apache-modules
data-management
always-on-top
spring-mongo
conan
noclassdeffounderror
timestamping
textblock
python-cffi
calcite
pythonxy
360-degrees
replicaset
baseadapter
mojo
uno
hp-idol-ondemand
wicket-1.5
windows-rt
object-code
stripe.net
bittorrent-sync
nodeload
jomsocial
principalcontext
jmenubar
colon
notifyjs
postgres-xc
mongo-jackson-mapper
tfs-sdk
session-0-isolation
xmlwriter
jsplitpane
zend-pdf
instance-variables
opends
mkannotation
navigationcontroller
mmc3
database-deadlocks
kohana-auth
asdoc
dm
powergui
wmd-editor
tso
index.dat
stretchblt

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