Hello guys my friend using a trick his upload cookies on his side sometime visitor click on log out button then cookies
not work his create a cookies activator please anyone tell me how its done this
i Just trying to say like this
set cookies(my target side like example.com )
how to log in on anyone using my username password using my HTML page
without knowing my account detail ....
So, first of all you need to make a page that'll set a cookie. For example consider this file named setCookie.php:
<?php
setcookie("user", "Alex Porter", time()+3600);
Now in your regular page HTML button:
<button id="cookieSetter">Set Cookie</button>
Now using jQuery send an AJAX request to setCookie.php file:
$('#cookieSetter').click(function(e) {
e.preventDefault();
$.ajax({
type: "GET",
url: "setCookie.php.php"
});
});
<?php
// you should start the session before any html
session_start();
// Creating some session variables like this
$_SESSION['pseudo'] = 'pseudo';
$_SESSION['password'] = 'password';
setcookie('pseudo', 'whatever', time() + 365*24*3600, null, null, false, true); // Setting up a cookie
setcookie('location', 'Russia', time() + 365*24*3600, null, null, false, true); // Just another one...
// And only after that you cant write html code.
?>
<!DOCTYPE html>
<html>
<head>
<title>Your page Title</title>
</head>
<body>
<p>
Hello <?php echo $_SESSION['pseudo']; ?> !<br />
You are in (login.php).
</p>
<p>
Hey ! I remember you !<br />
Your name is <?php echo $_COOKIE['pseudo']; ?> and you are located in <?php echo $_COOKIE['location']; ?> is that true?
</p>
<p>
Log out<br />
</p>
</body>
</html>
Related
I'm trying to make some php message sender and receiver Pages.
From the "Admin.php" page, administrator can send messages to the website visitors. And the "receiver.php" page is the visitor's inbox.
Here is the codes:
Admin.php:
<form method="post" action="sender.php">
<input type="text" name="message">
<input type="submit" value="Submit">
</form>
Sender.php:
<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$message = $POST["message"];
echo "data: {$message}\n\n";
flush();
?>
Receiver.php:
<!DOCTYPE html>
<html>
<body>
<h1>Getting server updates</h1>
<div id="result"></div>
<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("sender.php");
source.onmessage = function(event) {
document.getElementById("result").innerHTML += event.data + "<br>";
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>
why doesn't this work?
The problem is that you are trying to use "sender.php" to do two things.
From the admin form you need to submit to one php script that will store the messages, in a database of some kind.
Then in "receiver.php" you need to connect to a different PHP script, whose job is to keep polling that database for new entries, and when it sees one it should send it to the client. This latter PHP script will run in an infinite loop.
Hi I have to develop a mobile application using cross platform technology(HTML,CSS,JAVASCRIPT) wherein I need to send data to server and receive data from server.so I thought to use ajax so I tried below given code.
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("http://10.16.10.188/login/Hello.txt");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button>Get External Content</button>
</body>
</html>
The above code is working when I keep this html and text file on wamp server in same directory. but its not working when I keep this html file in my android asset folder and text file on server.it is not giving any response.could someone please help me to get this done.thank you so much
I was able to solve the problem by using jsonp in below given code.
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.10.1.min.js">
</script>
<script>
$.ajax({
url:"http://10.16.10.188/login/loginValidator.php",
dataType: "jsonp",
success:function(data,status){
if(status=='success')
{
alert("Data: " + data.fullname + "\nStatus: " + status);
var val = data.fullname;
$("#imchanged").html(val);
}
}
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<button id="imchanged">Get External Content</button>
</body>
</html>
Below is loginValidator.php code where my html points.
<?php
$array = array(
'fullname' => 'Jeff Hansen',
'address' => 'somewhere no.3'
);
$data = json_encode($array);
echo $_GET['callback']."(".$data.")";
?>
Using above given code I am able to invoke php file from mobile emulator and get the response from server.
I am trying to make -
an android WEB application
with phonegap
layout with JqueryMobile
What Im doing -
An html form that takes ID, name, and address as input
'Serialize's this data using ajax
makes a json object out of it
Should send it to a file called 'connection.php'
Where, this data is put into a database (MySql)
Other details -
My server is localhost, Im using xampp
I have already created a database and table using phpmyadmin
The problem -
My html file, where my json object is created, does not connect to the php file which is hosted by my localhost
Here is my COMPLETE html file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- Change this if you want to allow scaling -->
<meta name="viewport" content="width=default-width; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<title>Trial app</title>
<link rel="stylesheet" href="thestylesheet.css" type="text/css">
<script type="text/javascript" charset="utf-8" src="javascript1.js"></script>
<script type="text/javascript" charset="utf-8" src="javascript2.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-1.8.0.js"></script>
<script>
$(document).ready(function () {
$("#btn").click( function() {
alert('hello hello');
$.ajax({
url: "connection.php",
type: "POST",
data: {
id: $('#id').val(),
name: $('#name').val(),
Address: $('#Address').val()
},
datatype: "json",
success: function (status)
{
if (status.success == false)
{
alert("Failure!");
}
else
{
alert("Success!");
}
}
});
});
});
</script>
</head>
<body>
<div data-role="header">
<h1>Heading of the app</h1>
</div><!-- /header -->
<div data-role="content">
<form id="target" method="post">
<label for="id">
<input type="text" id="id" placeholder="ID">
</label>
<label for="name">
<input type="text" id="name" placeholder="Name">
</label>
<label for="Address">
<input type="text" id="Address" placeholder="Address">
</label>
<div id="btn" data-role="button" data-icon="star" data-theme="e">Add record</div>
<!--<input type="submit" value="Add record" data-icon="star" data-theme="e">
-->
</form>
</div>
</body>
</html>
And here is my 'connection.php' hosted by my localhost
<?php header('Content-type: application/json');
$server = "localhost";
$username = "root";
$password = "";
$database = "jqueryex";
$con = mysql_connect($server, $username, $password);
if($con) { echo "Connected to database!"; }
else { echo "Could not connect!"; }
//or die ("Could not connect: " . mysql_error());
mysql_select_db($database, $con);
/*
CREATE TABLE `sample` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`Address` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
)
*/
$id= json_decode($_POST['id']);
$name = json_decode($_POST['name']);
$Address = json_decode($_POST['Address']);
$sql = "INSERT INTO sample (id, name, Address) ";
$sql .= "VALUES ($id, '$name', '$Address')";
if (!mysql_query($sql, $con)) {
die('Error: ' . mysql_error());
} else {
echo "Comment added";
}
mysql_close($con);
?>
My doubts:
No entry is made in my table 'sample' when i view it in phpmyadmin
So obviously, i see no success messages either
I dont get any errors, not from ajax and neither from the php file.
Stuff Im suspecting:
Should i be using jsonp instead of json? Im new to this.
Is there a problem with my php file?
Perhaps I need to include some more javascript files in my html file?
I assume this is a very simple problem so please help me out! I think there is just some conceptual error, as i have only just started with jquery, ajax, and json.
Thank you.
A FEW EDITS:
I was getting the following syntax errors:
Connected to database!
Notice: Undefined index: id in C:\xampp\htdocs\connection.php on line 28
Notice: Undefined index: name in C:\xampp\htdocs\connection.php on line 31
Notice: Undefined index: Address in C:\xampp\htdocs\connection.php on line 34
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '', '')' at line 1
So i changed my code to
if (isset($_POST['id']))
$id= json_decode($_POST['id']);
if (isset($_POST['name']))
$name = json_decode($_POST['name']);
if (isset($_POST['Address']))
$Address = json_decode($_POST['Address']);
Still getting the same errors
Please help!
As you're using android so direct connection.php won't work, here is the general method to get this done:
http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/
After you setup things given in above link, the network address you'll get will be something like 10.0.0.2 then change your server to http://10.0.0.2/connection.php where connection.php is placed in htdocs directory.
Above step is necessary because android treats localhost as its own device localhost and doesn't pick the system's localhost directly.
Comment under this answer further to ask if you have more issues.
You can use JSONP for ajax request in Phonegap. But for that, you have to use Cross domain request to the server page using JSONP. Here you have to use callback method.
Just go through my post $.ajax() on phonegap.
And one more thing, dont make request from android to the localhost. Just put your file in webserver and try to make request.
Please change this script from :
$sql = "INSERT INTO sample (id, name, Address) ";
$sql .= "VALUES ($id, '$name', '$Address')";
To:
$sql = "INSERT INTO sample (id, name, Address) ";
$sql .= "VALUES ('$id', '$name', '$Address')";
Add the character ' around $id
I'm a beginner in jQuery area and I have simple question like this :
I want to load (AJAX) MySQL result in array, let's say :
$row[0] = first name
$row[1] = last name
$row[2] = phone number
I have no problem with PHP part, but I have difficulties to display each of that array content on different id. because syntax I found loads everything processed by PHP :
<script type="text/javascript">
$(document).ready(function(){
$('#mysql-result').load('ajax.php');
});
</script>
how to get 'First Name', 'Last Name' and 'Phone Number' from PHP with only one time load and still I can put the result in different . thank you.
UPDATE
I give you real example about what I need. Here's my HTML file named ajax.html :
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ajax Trial</title>
</head>
<body>
<div id = "fistname"><!-- ajax result goes here --></div>
<div id = "lastname"><!-- ajax result goes here --></div>
<div id = "phonenumber"><!-- ajax result goes here --></div>
</body>
</html>
and here's my PHP file, named ajax.php :
<?php
require_once 'config-min.php';
$con = mysql_connect($DbServer,$DbUser,$DbPassword);
mysql_select_db($DbName, $con);
$result = mysql_query("SELECT FirstName, LastName, PhoneNumber FROM User WHERE ID = '201' LIMIT 1");
$row = mysql_fetch_array($result);
echo $row[0];
echo $row[1];
echo $row[2];
mysql_close($con);
?>
now, my question still same... how to get this PHP result (3 echos), load once, then displayed in those 3 different divs
I too wanted to do something like you wish to.And I did the following code and It worked. Hope this helps you too.
<script type="text/javascript" src="/jquery.js"></script>
<script>
$(document).ready(function(){
$("#form_plat").submit(function(e){
var str = $(this).serialize();
row[0]=$('#First_name').val();
row[1]=$('#last_name').val();
row[2]=$('#phonenumber').val();
$.ajax({
type: "POST",
url : 'Insert_Into.pl', //if you wish to store in database
data : {'firstname_name':row[0],'last_name': row[1],'phonenumber':row[2]},
beforeSend: function() {
console.log("hey i am here");
},
success: function(){
$('#note').html('Thank you for your submission!');
$('#note').hide();
$("#fields").fadeOut('slow');
}
});
return false;
});
});
</script>);
Have you tried adding to your php code:
echo $firstname.' '.$lastname.' '.$phonenumber;
I just created a simple facebook app. I would like to add a simple html form that posts values to the same file. I wrote the code below, but it doesn't work.
When I type something into the text box of the form and hit submit, the page reloads but it doesn't get any values.
I can't figure out how to post data to the fb app on a canvas page. I would be grateful if you could help me to fix my code. Thanks.
<?php
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '229924173724291',
'secret' => '79e2bdaaa52bb3b80ea2f5e4c0f20d3e',
));
$user = $facebook->getUser();
if ($user) {
$me = $facebook->api('/me');
} else {
$loginUrl = "https://www.facebook.com/dialog/oauth?client_id=229924173724291&redirect_uri=https://apps.facebook.com/tnxkapp/&scope=publish_stream";
echo "<script>top.location.href=\"{$loginUrl}\"</script>";
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<? print($_POST[name]); ?>
<form action="https://apps.facebook.com/tnxkapp/" method="post">
<input type="text" name="name" value="<?php print($name); ?>" />
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
Post to your actual app URL http://yourdomain.com/appfolder not the apps.facebook.com. You're essentially trying to post info to facebook not your app with what your doing now.