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

How to add a class alias in Laravel
Select all rows from table in Yii
How to retrieve all table names from database?
PHP - How can i use str_replace in that situation?
get the value of a child
how to use my description(meta description) as a second title in joomla2.5
Can't retrieve data from MongoDb
Where is php.ini file of php_fpm?
laravel migration creates different schema
How to create facebook page with PHP or CURL?
How to convert INR to USD before passing to paypal in opencart
How to know the Dynamodb updateItem response status in AWS SDK for PHP
How can I test why sendmail / php isn't working?
Retrieve table data from another webpage using PHP
Extremely confusing (And infuriating) PHP/HTML problems
What is the facebook.com/sharer.php ios/android url schema for mobile websites?

Categories

HOME
list
gaming
yahoo-weather-api
bots
softlayer
initialization
biztalk
moodle-api
material-components
capistrano
ui-automation
cdi
phpmqtt
graphql-js
timber
yahoo
xades4j
game-maker
clish
pm2
cuba-platform
jodatime
sql-injection
complexity-theory
texas-instruments
bnf
android-5.1.1-lollipop
robolectric
gmp
coroutine
renderscript
spam
node-webkit
bosun
multi-upload
generator
chronicle-queue
tortoisemerge
network-analysis
points
xcrun
winrm
db2-luw
express-session
numerics
assertions
cordys-opentext
cartopy
android-n
linq.js
robust
dagger
minikube
spooler
permission-denied
code-push
qvtkwidget
cognos-tm1
petsc
thread-exceptions
livereload
dcount
visual-studio-monaco
piping
ajaxmin
gravatar
helm
self
android-studio-import
supercomputers
ngcordova
modern.ie
componentart
erlog
whitespace-language
fuseesb
innerhtml
kognitio-wx2
operands
famo.us
juttle
iplimage
siena
rpg
network-printers
application-blocks
pbkdf2
acitree
iirf
mp4parser
hints
flv
gitx
clrprofiler
cakeyframeanimation
netstream
affinetransform
data-dump
raw-data
facebook-fbml
autobench
efs
twitter-feed
code-camp
word-automation

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