Notice: Undefined index: confirm in C:\xampp\htdocs\assurance\confirmation.php on line 98
$confirm = $_POST['confirm'];
<label> Retype Password </label>
<input type="password" name="confirm" />
Notice: Undefined index: confirm in C:\xampp\htdocs\assurance\confirmation.php on line 98
$confirm = $_POST['confirm'];
<label> Retype Password </label>
<input type="password" name="confirm" />
You're probably running the form-handling code unconditionally, whether a form submission actually occurred or not.
You need something like:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['confirm'])) {
... a post occured, and the confirm field was submitted
}
}
... show the form.
You're attempting to assign the variable $confirm the value of $_POST['confirm'] when it hasn't been set. Add a check to the code to avoid the error.
Change:
$confirm = $_POST['confirm'];
To:
$confirm = ( isset($_POST['confirm'] ) ) ? $_POST['confirm'] : '';
did you submit the form?
by the way to espace the notice use
if(isset($_POST["confirm"])
Please check first:
Do you have a <form>
-Tag before your <input>
?
<form method="POST" action="path/to/file.php"><input name="confirm" type="password"> </form>
Do you have a button?
If you have something like a login form, you need a button to "submit"
<input type="submit">
Then write in your file:
if($_SERVER['REQUEST_METHOD'] == 'POST'){ if(isset($_POST['confirm']){
/* Do whatever you want */
}
}