When you press Register, it should add an form with some inputfields but it´s not working.
<form>
<input Action="SlutProjekt.php" type="submit" alt="Submit" method="post" name= "Register" value="Register" id="input">
</form>
<?php
if(isset($_SESSION['Register'])){
$RegisterPost = htmlspecialchars($_POST["Register"]);
?>
<li>
<form>
<input type="email" Action="SlutProjekt.php" method="post" name="RegisterEmail" placeholder="Email" >
<input type="password" Action="SlutProjekt.php" method="post" name="RegisterPw" placeholder="********" >
<input type="text" Action="SlutProjekt.php" method="post" name="RegisterAdress" placeholder="Adress" >
<input type="submit" Action="SlutProjekt.php" method="post" name="RegisterConfirm" alt="Submit" value="Register">
</form>
</li>
<?php } ?>
Ok so now after your edit
this
<form>
<input Action="SlutProjekt.php" type="submit" alt="Submit" method="post" name= "Register" value="Register" id="input">
</form>
Should be more like this
<form action="SlutProjekt.php" method="post" >
<input type="submit" alt="Submit" name="Register" value="Register" id="input">
</form>
You have a submit button without a form. Start by wraping your button around a form
element:
<form action="SlutProjekt.php" method="post">
<input type="submit" alt="Submit" name= "Register" value="Register" id="input">
</form>
Then wrap the PHP logic in <?php ... ?>
. Also, the value of the 'Register' input is in the $_POST superglobal array non in $_SESSION
if(isset($_POST['Register'])
{
$register = $_POST['Register'];
echo " <YOUR CONTENT HERE> ";
}
Note that this will only work if the code you posted comes from SlutProjekt.php
You confused the location of your method="POST" action="SlutProjekt.php"
. Replace your form with this code:
<form method="POST" action="SlutProjekt.php">
<input type="email" name="RegisterEmail" placeholder="Email" >
<input type="password" name="RegisterPw" placeholder="********" >
<input type="text" name="RegisterAdress" placeholder="Adress" >
<input type="submit" name="RegisterConfirm" alt="Submit" value="Register">
</form>
As far as I know, I think you are messing up a few things in your code.
First, ¿where are the php tags? All the php code needs to be written inside the php tags. That would be:
<?php
echo "exmple code";
?>
Second, your html form code doesn´t make any sense. The html <input>
tag in the first row of your code must be a <form>
tag. Because of this, you´ll need to close the html form accordingly at the end of the documment or where ever you need it. That would be </form>
.
As for your <input>
tags, the "action" and "method" properties have to be defined only once in the <form>
tag, they should not appear inside your <input>
tags.
That echo
sentence is prety weird. In any case, echo sentences have to be written between quotes if you want the content to be treated as strings, which is the case if you want your php code to write the form code into your html documment.
Finally, your "action" property is targeting to SlutProjekt.php, so the result of submitting the form should be written in that file, not in this one. If the php code has to throw the results in the same php file where your form is, you need to use $_SERVER['PHP_SELF'] method. You should investigate that.
Cheers!