Commit 3c125984 authored by Jessica Suszek's avatar Jessica Suszek

Merged branch master into master

parents dcd49e73 b79213ce
<?php
$con = mysqli_connect("localhost", "thani001", "password", "thani001_travelapals");
$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, $userID, $email, $name, $dob, $password, $username);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["email"] = $email;
$response["name"] = $name;
$response["dob"] = $dob;
$response["username"] = $username;
$response["password"] = $password;
}
echo json_encode($response);
;?>
\ No newline at end of file
<?php
$con = mysqli_connect("localhost", "thani001", "password", "thani001_travelapals");
$email = $_POST["email"];
$name = $_POST["name"];
$dob = $_POST["dob"];
$password = $_POST["password"];
$username = $_POST["username"];
$statement = mysqli_prepare($con, "INSERT INTO user (email, name, dob, password, username) VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "sssss", $email, $name, $dob, $password, $username);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
......@@ -5,7 +5,7 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -14,7 +14,7 @@ import java.util.Map;
public class LoginRequest extends StringRequest{
private static final String LOGIN_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/Login.php";
private static final String LOGIN_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/LoginTDB.php";
private Map<String, String> params;
public LoginRequest(String username, String password, Response.Listener<String> listener){
......
......@@ -5,6 +5,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import com.android.volley.Response;
......@@ -25,10 +26,24 @@ public class MainMenuActivity extends AppCompatActivity {
final ImageButton ibUserImageButton = (ImageButton) findViewById(R.id.ibUserImageButton);
Intent intent = getIntent();
final String username = intent.getStringExtra("username");
final String name = intent.getStringExtra("name");
final String dob = intent.getStringExtra("dob");
final String email = intent.getStringExtra("email");
ibUserImageButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent userIntent = new Intent(MainMenuActivity.this, UserAreaActivity.class);
userIntent.putExtra("name", name);
userIntent.putExtra("username", username);
userIntent.putExtra("dob", dob);
userIntent.putExtra("email", email);
MainMenuActivity.this.startActivity(userIntent);
}
});
......@@ -56,5 +71,7 @@ public class MainMenuActivity extends AppCompatActivity {
MainMenuActivity.this.startActivity(myPlanIntent);
}
});
}
}
......@@ -22,10 +22,11 @@ public class RegisterActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final EditText etAge = (EditText) findViewById(R.id.etAge);
final EditText etDob = (EditText) findViewById(R.id.etDob);
final EditText etName = (EditText) findViewById(R.id.etName);
final EditText etUsername = (EditText) findViewById(R.id.etUsername);
final EditText etPassword = (EditText) findViewById(R.id.etPassword);
final EditText etEmail = (EditText) findViewById(R.id.etEmail);
final Button btnRegister = (Button) findViewById(R.id.btnRegister);
......@@ -35,7 +36,9 @@ public class RegisterActivity extends AppCompatActivity {
final String name = etName.getText().toString();
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
final int age = Integer.parseInt(etAge.getText().toString());
final String dob = etDob.getText().toString();
final String email = etEmail.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>(){
......@@ -62,10 +65,11 @@ public class RegisterActivity extends AppCompatActivity {
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, age, password, responseListener);
RegisterRequest registerRequest = new RegisterRequest(name, username, dob, email, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
......
......@@ -11,16 +11,17 @@ import java.util.Map;
public class RegisterRequest extends StringRequest {
private static final String REGISTER_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/Register.php";
private static final String REGISTER_REQUEST_URL = "http://doc.gold.ac.uk/~thani001/travelpals/RegisterTDB.php";
private Map<String, String> params;
public RegisterRequest(String name, String username, int age, String password, Response.Listener<String> listener){
public RegisterRequest(String name, String username, String dob, String email, String password, Response.Listener<String> listener){
super(Method.POST, REGISTER_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("name", name);
params.put("username", username);
params.put("password", password);
params.put("age", age + "");
params.put("dob", dob + "");
params.put("email", email);
}
@Override
......
......@@ -13,18 +13,22 @@ public class UserAreaActivity extends AppCompatActivity {
setContentView(R.layout.activity_user_area);
final EditText etUsername = (EditText) findViewById(R.id.etUsername);
final EditText etAge = (EditText) findViewById(R.id.etAge);
final EditText etDob = (EditText) findViewById(R.id.etDob);
final EditText etName = (EditText) findViewById(R.id.etName);
final EditText etEmail = (EditText) findViewById(R.id.etEmail);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
int age = intent.getIntExtra("age", -1);
String username = intent.getStringExtra("username");
Intent userIntent = getIntent();
String name = userIntent.getStringExtra("name");
String email = userIntent.getStringExtra("email");
String dob = userIntent.getStringExtra("dob");
String username = userIntent.getStringExtra("username");
etUsername.setText(username);
etName.setText(name);
etAge.setText(age + "");
etDob.setText(dob);
etEmail.setText(email);
}
}
......@@ -52,19 +52,18 @@ public class loginActivity extends AppCompatActivity {
if(success){
String name = jsonResponse.getString("name");
int age = jsonResponse.getInt("age");
String dob = jsonResponse.getString("dob");
String username = jsonResponse.getString("username");
String email = jsonResponse.getString("email");
Intent intent = new Intent(loginActivity.this, UserAreaActivity.class);
Intent intent = new Intent(loginActivity.this, MainMenuActivity.class);
intent.putExtra("name", name);
intent.putExtra("age", age);
intent.putExtra("dob", dob);
intent.putExtra("username", username);
intent.putExtra("email", email);
Intent intent1 = new Intent(loginActivity.this, MainMenuActivity.class);
//loginActivity.this.startActivity(intent);
loginActivity.this.startActivity(intent1); //Start main menu activity
loginActivity.this.startActivity(intent);
}else{
AlertDialog.Builder builder = new AlertDialog.Builder(loginActivity.this);
builder.setMessage("Login failed")
......
......@@ -17,20 +17,46 @@
android:ems="10"
android:id="@+id/etName"
android:hint="Full name"
android:layout_marginTop="76dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:layout_marginBottom="10dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:inputType="date"
android:ems="10"
android:id="@+id/etAge"
android:hint="Age"
android:layout_below="@+id/etName"
android:layout_alignStart="@+id/etUsername"
android:layout_marginTop="10dp" />
android:id="@+id/etDob"
android:hint="YYYY-MM-DD"
android:layout_marginBottom="10dp"
android:layout_below="@id/etName"
android:layout_alignStart="@id/etName" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etEmail"
android:hint="Email Address"
android:layout_marginBottom="10dp"
android:layout_alignStart="@id/etDob"
android:layout_below="@id/etDob"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etUsername"
android:hint="Username"
android:layout_below="@id/etEmail"
android:layout_alignStart="@+id/etEmail"
android:layout_marginBottom="10dp" />
<EditText
android:layout_width="wrap_content"
......@@ -39,28 +65,25 @@
android:ems="10"
android:id="@+id/etPassword"
android:hint="Password"
android:layout_marginBottom="10dp"
android:layout_below="@+id/etUsername"
android:layout_alignStart="@+id/etUsername"
android:layout_marginTop="17dp" />
android:layout_alignStart="@+id/etUsername" />
<Button
android:text="REGISTER"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnRegister"
android:layout_below="@+id/etPassword"
android:layout_marginTop="33dp"
android:layout_alignStart="@+id/etPassword"
android:layout_alignEnd="@+id/etPassword" />
android:layout_marginBottom="7dp"
android:layout_below="@id/etPassword"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etUsername"
android:hint="Username"
android:layout_marginTop="16dp"
android:layout_below="@+id/etAge"
android:layout_alignStart="@+id/etName" />
</RelativeLayout>
......@@ -33,9 +33,9 @@
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:inputType="date"
android:ems="10"
android:id="@+id/etAge"
android:id="@+id/etDob"
android:layout_below="@+id/textView2"
android:layout_alignStart="@+id/etUsername"
tools:ignore="LabelFor" />
......@@ -45,7 +45,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView3"
android:layout_below="@+id/etAge"
android:layout_below="@+id/etDob"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
tools:ignore="HardcodedText" />
......@@ -67,6 +67,28 @@
android:ems="10"
android:id="@+id/etName"
android:layout_below="@+id/textView3"
android:layout_alignStart="@+id/etAge"
android:layout_alignStart="@+id/etDob"
tools:ignore="LabelFor" />
<TextView
android:text="E-Mail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:id="@+id/textView4"
android:layout_below="@+id/etName"
android:layout_centerHorizontal="true"
tools:ignore="HardcodedText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etEmail"
android:layout_below="@+id/textView4"
android:layout_alignStart="@+id/etName"
tools:ignore="LabelFor" />
</RelativeLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment