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 6647039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:29:24+00:00 2026-05-26T00:29:24+00:00

i have a php file that process my registration form however it does not

  • 0

i have a php file that process my registration form however it does not display the error messages if the form has discrepancies (blank fields, etc.). Also, the captcha validation is not working.

This is the php code that process the form.

<?php
//Start session
session_start();

//Include database connection details
require_once('connect.php');

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
    die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
    die("Unable to select database");
}

//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
        $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
}

//Sanitize the POST values
$username = clean($_POST['username']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
$nickname = clean($_POST['nickname']);
$email = clean($_POST['email']);
$code = clean($_POST['code']);

//Input Validations
if($username == '') {
    $errmsg_arr[] = 'Username missing';
    $errflag = true;
}
if($password == '') {
    $errmsg_arr[] = 'Password missing';
    $errflag = true;
}
if($cpassword == '') {
    $errmsg_arr[] = 'Confirm Password missing';
    $errflag = true;
}
if($nickname == '') {
    $errmsg_arr[] = 'nickname missing';
    $errflag = true;
}
if($email == '') {
    $errmsg_arr[] = 'Email Address missing';
    $errflag = true;
}
if( strcmp($password, $cpassword) != 0 ) {
    echo "Password Do not match";
    $errmsg_arr[] = 'Passwords do not match';
    $errflag = true;
}




  include("../captcha/securimage.php");
  $img = new Securimage();
  $valid = $img->check($_POST['code']);

  if($valid == true) {
  echo "<center>Thanks, you entered the correct code.</center>";
  } else {
  echo "<center>Sorry, the code you entered was invalid.";
  }





//Check for duplicate login ID
if($login != '') {
    $qry = "SELECT * FROM employee_login WHERE username='$username'";
    $result = mysql_query($qry);
    if($result) {
        if(mysql_num_rows($result) > 0) {
            $errmsg_arr[] = 'Username already in use';
            $errflag = true;
        }
        @mysql_free_result($result);
    }
    else {
        die("Query failed");
    }
}

//If there are input validations, redirect back to the registration form
if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: ../register.php");
    exit();
}

//Create INSERT query
$qry = "INSERT INTO employee_login(username, password, email, nickname) VALUES('$username','".md5($_POST['password'])."','$email','$nickname')";
$result = @mysql_query($qry);

//Check whether the query was successful or not
if($result) {
    header("location: ../registergood.php");
    exit();
}else {
    die("Query failed");
}
?>

What might be wrong?

  • 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-05-26T00:29:25+00:00Added an answer on May 26, 2026 at 12:29 am

    Well, it’s not displaying your error messages because at no point in the code you’ve provided do you output those messages to the user. You store them in an array and later a session variable, but that’s it.

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

Sidebar

Related Questions

Alright, currently I have my SWF hitting a php file that will go and
I have a PHP script that processes file uploads. The script tries to organise
I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller% Like
I have a PHP client that requests an XML file over HTTP (i.e. loads
I have a PHP script that pushes the headers to allow a file to
I have some jQuery code. I have called an Ajax function file, file.php, that
i have a php file launching my exe. the exe does cout and the
I have a PHP file, Test.php, and it has two functions: <?php echo displayInfo();
I have a PHP page(registration.php) from where i would submit a file to another
I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php.

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.