diff --git a/etc/nginx/conf.d/cs4430.conf b/etc/nginx/conf.d/cs4430.conf index 4ea0071..ce02685 100644 --- a/etc/nginx/conf.d/cs4430.conf +++ b/etc/nginx/conf.d/cs4430.conf @@ -3,14 +3,14 @@ server { listen [::]:80; root /var/www/; - index landingPage.html + index index.html server_name _; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { - try_files $uri $uri/ /landingPage.html =404; + try_files $uri $uri/ /index.html =404; } location ~ \.php$ { diff --git a/var/www/phptest.php b/var/www/debug.php similarity index 92% rename from var/www/phptest.php rename to var/www/debug.php index 7a3066f..724c0e0 100644 --- a/var/www/phptest.php +++ b/var/www/debug.php @@ -49,6 +49,13 @@ echo ""; ?> +

$_POST

+ "; + print_r($_POST); + echo ""; + ?> +

$_SESSION

"; diff --git a/var/www/index.html b/var/www/index.html index 56eaff7..7de4bc8 100644 --- a/var/www/index.html +++ b/var/www/index.html @@ -13,13 +13,17 @@

Friendbook

- - - - - - - + +

+ +

+ +

+ +

+ +

+ diff --git a/var/www/landingPage.html b/var/www/landingPage.html deleted file mode 100644 index 9e86017..0000000 --- a/var/www/landingPage.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - -

Friendbook

- - - - - - - - - - - - diff --git a/var/www/login.php b/var/www/login.php index 8d23141..bf7bea5 100644 --- a/var/www/login.php +++ b/var/www/login.php @@ -1,5 +1,10 @@ @@ -17,7 +22,7 @@

Please Login

-
+ User:
Password: diff --git a/var/www/messageSender.php b/var/www/messageSender.php index d177c09..ad71a0e 100644 --- a/var/www/messageSender.php +++ b/var/www/messageSender.php @@ -7,7 +7,31 @@ body { } +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +$username = $_POST["name"]; +$message = $_POST["message"]; + +$query0 = "Select max(messageID) from messages"; +mysqli_query($conn, $query0) or die('Error querying database.'); +$maxID = mysqli_query($conn, $query0); +$maxID = $maxID + 1; +$query1 = "Insert into messages (messageID, sender, recipient, message, date, haveread) values({$maxID}, , {$username}, {$message}, NOW(), 'N')"; +mysqli_query($conn, $query1) or die('Error inserting into database.'); + +mysqli_close($conn); +?> diff --git a/var/www/nameSearch.php b/var/www/nameSearch.php index decdfef..e1660ad 100644 --- a/var/www/nameSearch.php +++ b/var/www/nameSearch.php @@ -20,10 +20,18 @@ if ($conn->connect_error) { } echo "Connected successfully"; -$query = "Select * from contacts where fname = " + $fname + " and lnam = " + $lname; +$query = "Select * from contacts where fname = {$fname} and lnam = {$lname}"; +mysqli_query($conn, $query) or die('Error querying database.'); -print $query; +$result = mysqli_query($conn, $query); +$row = mysqli_fetch_array($result); +while ($row = mysqli_fetch_array($result)) { + echo $row['fname'] . ' ' . $row['lnam'] . ': ' . $row['username'] .'
'; +} + + +mysqli_close($conn); ?> diff --git a/var/www/sendMessage.php b/var/www/sendMessage.php index 426962b..a5cfa98 100644 --- a/var/www/sendMessage.php +++ b/var/www/sendMessage.php @@ -9,33 +9,7 @@ body {

Send a message

- - -"> + Who are you sending it to?:


Message:
diff --git a/var/www/usernameSearch.php b/var/www/usernameSearch.php index 183ad88..82c39d0 100644 --- a/var/www/usernameSearch.php +++ b/var/www/usernameSearch.php @@ -7,6 +7,7 @@ body { connect_error) { die("Connection failed: " . $conn->connect_error); } -echo "Connected successfully"; -$query = "Select * from contacts where username = " + $username; +echo "
"; +$query = "Select * from contacts where username = {$username}"; +mysqli_query($conn, $query) or die('Error querying database.'); + +$result = mysqli_query($conn, $query0); +$row = mysqli_fetch_array($result); + +while ($row = mysqli_fetch_array($result)) { + echo $row['username'] . ': ' . $row['fname'] . ' ' . $row['lnam'] .'
'; +} print $query; + +mysqli_close($conn); ?>