Notifying user whose request has been accepted

This forum is a place to discuss questions about coding in the PHP programming language.
Post Reply
User avatar
Andrea
New User
Posts: 2
Joined: 24 May 2018, 08:46

Notifying user whose request has been accepted

Post by Andrea » 05 Jun 2018, 15:20

HELLO MR MACKENTYYY
Hidden Content
This board requires you to be registered and logged-in to view hidden content.
 ! Message from: Andrea
I hope it didnt bother you, I was just very scared and stressed out because I dont really know what I'm doing in math... And its my final project (I wouldve done the same a couple weeks ago with our programming project :)
So, I have been trying to make the user who requested a lunch and whose lunch was accepted go to the file accept_swap.php after logging in again. However, I have no clue how to do that. So, I have been trying things out. This thing below is my code:

Code: Select all

<?php
session_start();
// this file should be named login_process.php
$email = $_POST['email'];
$password = $_POST['password'];
$remember = $_POST['remember'];
include('database_inc.php');
// This sort of query is very unsafe.
$result = mysqli_query($connect,
    "SELECT * FROM users WHERE email = '$email';");
if (mysqli_num_rows($result) == 0) {
    $_SESSION['message_login_problem'] = true;
    header('location:new_register_login.php');
}
while ($row = mysqli_fetch_array($result)) {
    if ($row['password'] == $password)
    {
        $logged_in_id = $row['id'];
        $_SESSION['logged_in_id'] = $logged_in_id;
        $_SESSION['logged_in'] = TRUE;
        $_SESSION['email'] = $email;

        "SELECT * FROM swap_request WHERE (`id_owner_of_lunch` = $logged_in_id" and `status` = 'accepted' limit 1 ;");
    

        header('location:lunch_upload.php');
    } else {
        $_SESSION['message_login_problem'] = true;
        header('location:new_register_login.php');
    }
}
?>
I'm working on the "SELECT * FROM swap_request WHERE (`id_owner_of_lunch` = $logged_in_id" and `status` = 'accepted' limit 1 ;"); part but it just makes the rest of my code go orange and nothing is working (things are not the color they should be...) I think there is something wrong with the closing brackets at the end of that line of code, but I have compared it to the rest of the code of my website and that is the way it should be... I still have to add the header('location:accept_swap.php'); but I am not even sure if the line above (select from blah blah blah) is located correctly in my code. Because, if it is true I want it to go to accept_swap.php, but if it isnt, I still want it to go to lunch_upload.php, so is the location of that line correct in my code? I still have to work on it but I am not sure what to write under that line. "If true then header location blah blah blah"?? yo estoy confundida!! But I think I am going on the right track... at least I hope I am.

Thank you!!

Your fave student who worries about her finals :)
1 x
Andrea

Tags:

Post Reply