I Need some help with my script. When I go to the MySQL Database and insert a new User I can log in with my username and Password, which I can create through the MySQL database.
But my register-page.php script doesn't work somehow. It doesn't fill the database with new data from user Registration. Can you solve the Problem please? Thanks.
The Problem which appears is ERROR while Register
. It is my own error message.
<?php
session_start();
if(isset($_SESSION['sig']))
{
echo('<script> window.location="index.php" </script>');
}
if(isset($_REQUEST['submit']))
{
$username = $_REQUEST['UserName'];
$password = $_REQUEST['UserPassword'];
include('db_login.php');
$query = mysqli_query($connection, "SELECT * FROM UserTable WHERE UserName='".$username."' AND UserPassword='".$password."'");
$row = mysqli_fetch_array($query);
if(empty($row))
{
echo('<script> alert("This User could not be found, please try again!"); </script>');
}
else
{
$_SESSION['sig'] = "OK";
$_SESSION['UserName'] = $username;
echo('<script> window.location="dashboard.php" </script>');
}
}
if(isset($_REQUEST['submitregister']))
{
$username_reg = $_REQUEST['UserName'];
$password_reg = $_REQUEST['UserPassword'];
include('db_login.php');
$query = mysqli_query($connection, "INSERT INTO UserTable (UserName, UserPassword) VALUES ('".$username_reg."','".$password_reg."');") or die ("ERROR while register");
echo('<script> window.location="dashboard.php" </script>');
}
?>
REGISTER-PAGE.php
<?php
session_start();
if(isset($_REQUEST['submitregister']))
{
$userinfo_reg = $_REQUEST['UserInfo'];
$username_reg = $_REQUEST['UserName'];
$password_reg = $_REQUEST['UserPassword'];
include('db_login.php');
// Melde alle PHP Fehler (siehe Changelog)
$query = mysqli_query($connection, "INSERT INTO UserTable (UserInfo, UserName, UserPassword) VALUES ('".$userinfo_reg."','".$username_reg."','".$password_reg."');") or die ("ERROR while register");
echo('<script> window.location="dashboard.php" </script>');
}
?>
INDEX.php
IMAGES:
https://www.file-upload.net/download-13475231/indexpage.PNG.html
https://www.file-upload.net/download-13475230/register-page.PNG.html
Please help me, thanks.