Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:25:43+00:00 2026-06-17T11:25:43+00:00

I have a registration script on my page, and it’s handled like this: <?php

  • 0

I have a registration script on my page, and it’s handled like this:

<?php
include "inc/config.php";
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $email = $_POST['email'];
        $pass = $_POST['pass'];
        $conditions = $_POST['conditions'];
        if($firstname==""||$lastname==""||$email==""||$pass==""||$conditions==""){
        echo "
        <p>Tiedoissa oli puutteita :(</p>
            <ul>";
            if($firstname == ""){
                echo "<li>Etunimi puuttuu.</li>";
            }
            if($lastname == ""){
                echo "<li>Sukunimi puuttuu. </li>";
            }
            if($email == ""){
                echo "<li>Sähköposti puuttuu. </li>";
            }
            if($pass == ""){
                echo "<li>Salasana puuttuu. </li>";
            }
            if($conditions == ""){
                echo "<li>Luitko ehdot? </li>";
            }
        echo "</ul>";
        return false;
        }
        $rq = "INSERT INTO Users (Firstname,Lastname,Email,Password) VALUES ($firstname,$lastname,$email,$pass)";
        if(!mysqli_query($dblink,$rq)){
            echo "Rekisteröityminen epäonnistui tuntemattomasta syystä! :(";
        }
        else{
            echo "Rekisteröinti onnistui!<br>
            Käyttäjätunnuksesi on <strong>$email</strong> ja salasanasi on <strong>$pass</strong>.<br>
            Voit nyt kirjautua sisään. 
            ";
        }


?>

I’m having troubles finding the right method of comparing the form value, as I’ve tried ==,=== and NULL on comparison.
But I’m always getting all of the error messages, or none of them. What I’m doing wrong?

Here’s the html of the form:

<form class="form-horizontal span6" method="post" id="registrationform">
          <div class="control-group">
            <label class="control-label">Etunimi</label>
            <div class="controls">
              <input type="text" name="firstname">
            </div>
          </div>
          <div class="control-group">
            <label class="control-label">Sukunimi</label>
            <div class="controls">
              <input type="text" name="lastname">
            </div>
          </div>
          <div class="control-group">
            <label class="control-label">Sähköposti</label>
            <div class="controls">
              <input type="text" name="email">
            </div>
          </div>
          <div class="control-group">
            <label class="control-label">Salasana</label>
            <div class="controls">
              <input type="password" name="pass">
            </div>
          </div>
          <div class="control-group">
            <div class="controls">
              <label class="checkbox">
                <input type="checkbox" name="newsletter"> Tilaan uutiskirjeen
              </label>
              <label class="checkbox">
                <input type="checkbox" name="conditions"> Hyväksyn ehdot
              </label>
              <button type="submit" class="btn btn-success" id="registerbtn">Rekisteröidy</button>
            </div>
          </div>
        </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:25:44+00:00Added an answer on June 17, 2026 at 11:25 am

    Since your code is not in a function hence return false; is not working as you expect, and code continues to execute below. Your comparisons may already be fine. Change that return false; to die();

    Ok so here is probably where the problem lies

    if($firstname=="" || $lastname=="" || $email=="" || $pass=="" || $conditions==""){
    

    You are checking for that and that check is working even when you dont submit the form and it appears like everything has an error. So you need to make that comparison only when the form is submitted and not while normal load. So wrap your php code around some isset like

    if(isset($_POST["firstname"]) && isset($_POST["lastname"]))
    {
     // all your php code
    }
    

    Other than that, your code is working fine. It compares like you expect it to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 'registration' page in PHP and I would like the script to
I have just finished writing my own php registration script from scratch and since
I have this registration page which works fine ,but for the email field I
I have working registration script the only problem is that i do not know
I have a registration page with the following code below: in the views: def
I have a registration page, and because of content issues we have to request
I have a registration form where this CSS rules apply. when user submits with
I have a web-site based on PHP, to which I would like to add
Say I have an HTML form like this to collect an email from a
I have a custom error script that displays custom error messages on a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.