Commit a4120222 authored by Tanmim Hanifa's avatar Tanmim Hanifa

Uploading final edits for final commit

parent 8cb633fb
<?php
require("password.php");
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM user1 WHERE username = ?");
mysqli_stmt_bind_param($statement, "s", $username);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $colUserID, $colEmail, $colGender, $colName, $colDob, $colPassword, $colUsername);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
if (password_verify($password, $colPassword)) {
$response["success"] = true;
$response["user_id"] = $colUserID;
$response["email"] = $colEmail;
$response["gender"] = $colGender;
$response["name"] = $colName;
$response["dob"] = $colDob;
$response["username"] = $colUsername;
}
}
echo json_encode($response);
?>
<!-- <?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$username = $_POST["username"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $user_id, $name, $username,$age, $password);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["user_id"] = $user_id;
$response["name"] = $name;
$response["age"] = $age;
$response["username"] = $username;
$response["password"] = $password;
}
echo json_encode($response);
?>
-->
<?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$user_id = $_POST["user_id"];
$statement = mysqli_prepare($con, "SELECT * FROM user1 WHERE user_id = ? ");
mysqli_stmt_bind_param($statement, "i", $user_id);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $user_id, $email, $gender,$name, $dob,$password,$username);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["user_id"]=$user_id;
$response["email"] = $email;
$response["gender"] = $gender;
$response["name"] = $name;
$response["dob"] = $dob;
$response["password"] = $password;
$response["username"] = $username;
}
echo json_encode($response);
?>
<?php
require("password.php");
$connect = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$name = $_POST["name"];
$dob = $_POST["dob"];
$email = $_POST["email"];
$username = $_POST["username"];
$password = $_POST["password"];
$gender = $_POST["gender"];
function registerUser() {
global $connect, $name, $gender, $dob, $email, $username, $password;
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$statement = mysqli_prepare($connect, "INSERT INTO user1 (name, gender, dob, email, username, password) VALUES (?, ?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "ssisss", $name, $gender, $dob, $email, $username, $passwordHash);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
}
function usernameAvailable() {
global $connect, $username;
$statement = mysqli_prepare($connect, "SELECT * FROM user1 WHERE username = ?");
mysqli_stmt_bind_param($statement, "s", $username);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
$count = mysqli_stmt_num_rows($statement);
mysqli_stmt_close($statement);
if ($count < 1){
return true;
}else {
return false;
}
}
function emailAvailable() {
global $connect, $email;
$statement = mysqli_prepare($connect, "SELECT * FROM user1 WHERE email = ?");
mysqli_stmt_bind_param($statement, "s", $email);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
$count = mysqli_stmt_num_rows($statement);
mysqli_stmt_close($statement);
if ($count < 1){
return true;
}else {
return false;
}
}
$response = array();
$response["success"] = false;
if (usernameAvailable() && emailAvailable()){
registerUser();
$response["success"] = true;
}
echo json_encode($response);
?>
//source for password hash - https://github.com/ircmaxell/password_compat/blob/master/lib/password.php
\ No newline at end of file
<?php
include 'dbconfig.php';
$conn = new mysqli($servername, $username, $password, $dbname);
$destination = $_POST['destination'];
$sql = "SELECT * FROM plans WHERE destination = '$destination'";
$result = $conn->query($sql);
if ($result->num_rows >0) {
// output data of each row
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$json = json_encode($tem);
}
} else {
$empty = array();
$json=json_encode($empty);
// echo "0 results";
}
echo $json;
$conn->close();
?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$user_id = $_POST["user_id"];
$date = $_POST["date"];
$destination = $_POST["destination"];
$sql = "SELECT * FROM plans WHERE user_id= '$user_id' ";
$result = $con->query($sql);
if ($result->num_rows <3) {
$statement = mysqli_prepare($con, "INSERT INTO plans ( destination,date,user_id) VALUES (?,?,?) ");
mysqli_stmt_bind_param($statement, "ssi", $destination,$date,$user_id);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
}
?>
\ No newline at end of file
<?php
//This script is designed by Android-Examples.com
//Define your host here.
$servername = "localhost";
//Define your database username here.
$username = "id899753_groupel";
//Define your database password here.
$password = "travel";
//Define your database name here.
$dbname = "id899753_travelb";
?>
\ No newline at end of file
<?php
include 'dbconfig.php';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$destination= $_POST["destination"];
$user_id=$_POST["user_id"];
$sql = "SELECT * FROM user1 INNER JOIN plans ON user1.user_id=plans.user_id WHERE destination='$destination' and plans.user_id!='$user_id'";
$result = $conn->query($sql);
if ($result->num_rows >0) {
// output data of each row
while($row[] = $result->fetch_assoc()) {
$tem = $row;
//$tem["success"]=true
$json = json_encode($tem);
}
} else {
$empty = array();
$json=json_encode($empty);
// echo "0 results";
}
echo $json;
$conn->close();
?>
\ No newline at end of file
<?php
include 'dbconfig.php';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$userID= $_POST['user_id'];
$sql = "SELECT * FROM plans WHERE user_id= '$userID' ";
$result = $conn->query($sql);
if ($result->num_rows >0) {
// output data of each row
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$json = json_encode($tem);
}
} else {
$empty = array();
$json=json_encode($empty);
// echo "0 results";
}
echo $json;
$conn->close();
?>
\ No newline at end of file
<?php
include 'dbconfig.php';
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$user_id=$_POST["user_id"];
$sql = "SELECT * FROM user1 INNER JOIN message ON user1.user_id=message.sender WHERE receiver='$user_id'";
$result = $conn->query($sql);
if ($result->num_rows >0) {
// output data of each row
while($row[] = $result->fetch_assoc()) {
$tem = $row;
//$tem["success"]=true
$json = json_encode($tem);
}
} else {
$empty = array();
$json=json_encode($empty);
// echo "0 results";
}
echo $json;
$conn->close();
?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$plan_id = $_POST["plan_id"];
$statement = mysqli_prepare($con, "DELETE FROM plans WHERE plan_id = ? ");
mysqli_stmt_bind_param($statement, "s", $plan_id);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$content = $_POST["content"];
$sender = $_POST["sender"];
$receiver = $_POST["receiver"];
$statement = mysqli_prepare($con, "INSERT INTO message ( content,sender,receiver) VALUES (?, ?,?) ");
mysqli_stmt_bind_param($statement, "sss", $content,$sender,$receiver);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "id899753_groupel", "travel", "id899753_travelb");
$user_id = $_POST["user_id"];
$name=$_POST["name"];
$username=$_POST["username"];
$dob=$_POST["dob"];
$email=$_POST["email"];
$statement = mysqli_prepare($con, "update user1 set email='$email',name='$name',dob='$dob',username='$username' where user_id='$user_id' ");
// mysqli_stmt_bind_param($statement, "s", $user_id);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
\ No newline at end of file
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/TravelB.iml" filepath="$PROJECT_DIR$/TravelB.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.mohamed.travelb"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})