Hello there humans of stackoverflow! So, i'm quite new in PHP and started working on a new website application project. The application has to contain a user with userinformation ex. first- and lastname, streetname- and number, postal code, city, phone, email etc.
Introduction
I looked at a tutorial for secure login php and register from Wikihow, which for me as a rookie, is a very well explanied tutorial. However, the tutorial contains the register.php with Username, Email and Password, I would only like my registerform to contain more inputfields firstname, lastname, streetname, streetnumber, streetfloor, streetside, postalcode, city, phonenumber and mobilenumber as well.
See the following HTML5 Bootstrap Wizard Form including PHP 'register.php' below:
- 1Trin 1
- 2Trin 2
- 3Trin 3
As you can see the form Wizard has 3 steps. Step 1, Step 2 and Step 3. The problem is that the input from Step 2 is not being or actucally any input is not being saved in the database. I think it has something to do with the following code:
action="" method="post" name="registration_form"
When putting the step2 inputfields inside the step1 container it works fine. But I want the registration form to work as a step by step.
Se the register.inc.php code below:
*Please note that some code is missing, as it is not relevant and to make the code more viewable:
include_once 'db_connect.php';
include_once 'psl-config.php';
$error_msg = "";
if (isset($_POST['username'], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['p'], $_POST['streetname'], $_POST['streetnumber'], $_POST['streetfloor'], $_POST['streethand'], $_POST['postalcode'], $_POST['city'], $_POST['phonenumber'], $_POST['mobilenumber'])) {
// Sanitize and validate the data passed in
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$firstname = filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING);
$lastname = filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
$streetname = filter_input(INPUT_POST, 'streetname', FILTER_SANITIZE_STRING);
$streetnumber = filter_input(INPUT_POST, 'streetnumber', FILTER_SANITIZE_STRING);
$streetfloor = filter_input(INPUT_POST, 'streetfloor', FILTER_SANITIZE_STRING);
$streethand = filter_input(INPUT_POST, 'streethand', FILTER_SANITIZE_STRING);
$postalcode = filter_input(INPUT_POST, 'postalcode', FILTER_SANITIZE_STRING);
$city = filter_input(INPUT_POST, 'city', FILTER_SANITIZE_STRING);
$phonenumber = filter_input(INPUT_POST, 'phonenumber', FILTER_SANITIZE_STRING);
$mobilenumber = filter_input(INPUT_POST, 'mobilenumber', FILTER_SANITIZE_STRING);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Not a valid email
$error_msg .= 'The email address you entered is not valid
}
// Insert the new user into the database
if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, firstname, lastname, email, password, salt, streetname, streetnumber, streetfloor, streethand, postalcode, city, phonenumber, mobilenumber) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
$insert_stmt->bind_param('ssssssssssssss', $username, $firstname, $lastname, $email, $password, $random_salt, $streetname, $streetnumber, $streetfloor, $streethand, $postalcode, $city, $phonenumber, $mobilenumber);
// Execute the prepared query.
if (! $insert_stmt->execute()) {
header('Location: ../error.php?err=Registration failure: INSERT');
}
}
header('Location: ./register_success.php');
}
}
?>
You can take a look at genber.dk/wirio/register.php
Can anybody help please??
No comments:
Post a Comment