Hi,
i have a simple form and i will check if the submit button is click or not and i check the input of the fields.
but what ever i do i came in the else loop also if i click the submit button.
if i change the code in is the button not click and i click submit then i come in the if loop and every think is fine.
for the moment i am confused.
I am a beginner in php i hope somebody can help.
Thank’s a lot.
index.php
[php]
Sign up
<br>
<input type="text" name="first" placeholder="Firstname">
<br>
<input type="text" name="last" placeholder="Lastname">
<br>
<input type="text" name="email" placeholder="eMail">
<br>
<input type="text" name="uid" placholder="Username">
<br>
<input type="password" name="pwd" placholder="Password">
<br><br>
<button type="submit" name"submit" class="button">Sign up</button>
signup.inc.php
[php]
<?php // Check if the user have click the signup button if (isset($_POST['submit'])) { // Then we include the database //include_once 'dbh.inc.php'; // And we get the data from the signup form $first = $_POST['first']; $last = $_POST['last']; $email = $_POST['email']; $uid = $_POST['uid']; $pwd = $_POST['pwd']; // Check if inputs are empty if (empty($first) || empty($last) || empty($email) || empty($uid) || empty($pwd)) { header("Location: ../index.php?signup=empty"); exit(); } else { // Check if input characters are valid if (!preg_match("/^[a-zA-Z]*$/", $first)||(!preg_match("/^[a-zA-Z]*$/", $last))) { header("Location: ../index.php?signup=char"); exit(); } else { // Check if email is valide if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { header("Location: ../index.php?signup=invalidemail"); exit(); } else { header("Location: ../index.php?signup=success"); exit(); } } } } else { header("Location: ../index.php?signup=error"); exit(); } [/php] [/php]