220061
Well-Known Coder
This is pretty easy but honestly I just can't seem to find what the problem is? I want to post my variabels to antoher page but when I do for example $_POST['lastname']; on the other page it says Warning: Undefined array key "lastname" in C:\xampp\htdocs\huizen_huren_website\registerback.php on line 15
this is my code for register.php
backend ( the other page registerback.php)
ty in advance
this is my code for register.php
HTML:
<?php session_start();?>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!DOCTYPE html>
<html lang="nl">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css">
<!-- Website CSS style -->
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<!-- Website Font style -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<!-- Google Fonts -->
<link href='https://fonts.googleapis.com/css?family=Passion+One' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oxygen' rel='stylesheet' type='text/css'>
<title>Admin</title>
</head>
<style>
/*
/* Created by Filipe Pina
* Specific styles of signin, register, component
*/
/*
* General styles
*/
body, html{
height: 100%;
background-repeat: no-repeat;
background-color: #17a2b8;
font-family: 'Oxygen', sans-serif;
}
.main{
margin-top: 70px;
}
h1.title {
font-size: 50px;
font-family: 'Passion One', cursive;
font-weight: 400;
}
hr{
width: 10%;
color: #fff;
}
.form-group{
margin-bottom: 15px;
}
label{
margin-bottom: 15px;
}
input,
input::-webkit-input-placeholder {
font-size: 11px;
padding-top: 3px;
}
.main-login{
background-color: #fff;
/* shadows and rounded borders */
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
}
.main-center{
margin-top: 30px;
margin: 0 auto;
max-width: 330px;
padding: 40px 40px;
}
.login-button{
margin-top: 5px;
}
.login-register{
font-size: 11px;
text-align: center;
}
</style>
<body>
<div class="container">
<div class="row main">
<div class="main-login main-center">
<form class="form-horizontal" action="registerback.php" method="POST" >
<div class="form-group">
<label for="firstname" class="cols-sm-2 control-label" id="firstname">Firstname</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="firstname" id="firstname" placeholder="Enter your firstname"/>
</div>
</div>
</div>
<div class="form-group">
<label for="email" class="cols-sm-2 control-label" id="email">Your Email</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="email" id="email" placeholder="Enter your Email"/>
</div>
</div>
</div>
<div class="form-group">
<label for="lastname" class="cols-sm-2 control-label" id="lastname">lastname</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-users fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" name="lastname" id="lastname" placeholder="Enter your lastname"/>
</div>
</div>
</div>
<div class="form-group">
<label for="password" class="cols-sm-2 control-label" id="password">Password</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" name="password" id="password" placeholder="Enter your Password"/>
</div>
</div>
</div>
<div class="form-group ">
<button type="button" class="btn btn-primary btn-lg btn-block login-button"><a href="registerback.php">Register</a></button>
</div>
<div class="login-register">
<a href="login.php">Login</a>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="assets/js/bootstrap.js"></script>
</body>
</html>
backend ( the other page registerback.php)
PHP:
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_POST["email"]) && $_POST["password"] === true){
header("location: welcome.php");
exit;
}
// Include config file
include "config.php";
echo $_POST['lastname'];
ty in advance
it's