The redirect does not work.

Asked 2 years ago, Updated 2 years ago, 60 views

I'd like to redirect you to the login form from the link in the body of the HTML mail, but it's not working and I'm stuck.Could someone give me some advice?

error message

404/The requested URL/kento/register/login.php was not found on this server.

source code

<?php

if(isset($_SERVER['REQUEST_METHOD')&$_SERVER['REQUEST_METHOD']==='POST'){
    ini_set('display_errors',1); // Display errors on screen
    error_reporting(E_ALL);
    session_start();

    $firstname=';
    $lastname=';
    $email=';
    $phone=';
    $birthdate=';
    $username=';
    $password=';

    if(isset($_POST['firstname'])&isset($_POST['lastname'])&isset($_post['email'])
            &isset($_POST['phone'])&isset($_POST['birthdate'])&isset($_POST['username'])
            &isset($_POST['password'])){
        $_SESSION["USER"] = 'USER';
        header("Location: https://Applications/MAMP/htdocs/kento/php/microblog/login.php");
        exit;
    }

    if(isset($_POST['email'])){
        echo "Please check the Email";
    } else{
        echo "Your Email is invalid, please check your Email address again";
    }

    $dsn='mysql:host=localhost;dbname=microblog';
    $user='root';
    $password='root';
    // $USER=$FILES['firstname']['lastname']['email']['phone']['birthdate']['username']['password'];
    try{
        $db = new PDO($dsn, $user, $password);
        $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
        $stmt = $db - > prepare("INSERT INTO users (firstname, lastname, email, phone, username, password)
                VALUES(:firstname,:lastname,:email,:phone,:username,:password);
        $stmt->execute(array(
                    ':firstname' = > $_POST ['firstname'],
                    ':lastname' = > $_POST ['lastname'],
                    ':email'=>$_POST ['email',
                    ':phone'=>$_POST ['phone'],
                    ':username' = > $_POST ['username'],
                    ':password'=>$_POST ['password']
                    ));

    } catch(PDOException$e){
        die('error:'.$e->getMessage());
    }

    $to=$_POST ['email'];
    $subject='Email verification';
    $message='
        <html>
        <head>
        <title>sending link</title>
        </head>
        <body>
        <a href="https://localhost:8080/MAMP/htdocs/kento/register/login.php">Click this link to activate your account!</a>
        </body>
        </html>
        ';
    $headers='MIME-Version: 1.0';
    $headers='Content-type:text/html; charset=iso-8859-1';

    mail($to,$subject,$message,$headers);
}

?>
<!DOCTYPE html>
<html>
<head></head>
<body>

<h2>Register your information</h2>

<form method="POST" action="register.php">
Fastname —<input type="text" name="firstname"><br>br>br>
Lastname —<input type="text" name="lastname"><br>br>br>
Email Address: <input type="text" name="email"><br>br>br>
Phone Number: <input type="text" name="phone"><br>br>br>
Birth Date: <input type="text" name="birthdate"><br>br>br>
Username: <input type="text" name="username"><br>br>br>
Password: <input type="text" name="password"><br>br>br>
<input type="submit" name="register" value="register">
</form>

</body>
</html>

php

2022-09-30 21:40

1 Answers

I solved myself by setting the route in the routes file.

Router::connect('/',array('controller'=>'Pages','action'=>'home'));
Router::connect('/signup', array('controller'=>'Users', 'action'=>'signup');
Router::connect('/login', array('controller'=>'Users', 'action'=>'login');
Router::connect('/profile', array('controller'=>'Users', 'action'=>'profile');
Router::connect('/search', array('controller'=>'Follows','action'=>'search'));
Router::connect('/logout', array('controller'=>'Users', 'action'=>'logout');


2022-09-30 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.