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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:48:13+00:00 2026-05-21T23:48:13+00:00

Before insert into mysql, how to make a word lenth judge ? that the

  • 0

Before insert into mysql, how to make a word lenth judge ? that the custom insert each part of word must be more than 3 letters and less than 50 letters? Thanks.

//if(strlen($_POST['firstname'])>=3 & strlen($_POST['lastname'])>=3){
$firstname = htmlspecialchars(trim($_POST['firstname']));
$lastname = htmlspecialchars(trim($_POST['lastname']));
$addClient  = "INSERT INTO contact (firstname,lastname) VALUES ('$firstname','$lastname')";
mysql_query($addClient) or die(mysql_error());
//}
  • 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-21T23:48:13+00:00Added an answer on May 21, 2026 at 11:48 pm

    You mean something like this?

    if($_SERVER['REQUEST_METHOD'] == "POST") {
      $fnlenght = strlen($_POST['firstname']);
      $lnlenght = strlen($_POST['lastname']);
    
      if(($fnlenght > 2 && $fnlength < 51) && ($lnlenght > 2 && $lnlenght < 51)) {
        $addClient = "INSERT INTO contact (firstname,lastname) VALUES ('".mysql_real_escape_string($_POST['firstname'])."','".mysql_real_escape_string($_POST['lastname']."')";
        mysql_query($addClient) or die(mysql_error());
      } else {
        echo "Lenght of first- and/or lastname was not correct.";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I insert something into a MySQL database using PHP and then immediately make
I wish to DELETE the data from a table before performing an INSERT INTO,
I'm writing a class to insert users into a database, and before I get
What's the best way to insert an element into a page's HEAD directly before
How can I insert a NULL value into a database field (MySQL) with char(2)?
I am trying to insert a row into a MySQL table, with the condition
I have a form that I am using to post data to mysql. Before
In PHP, I am escaping characters before insert in a MySQL database using mysql_real_escape_string
The INSERT into staffprofiles mysql query (near the bottom of the code) is getting
I'm using a prepared statement to insert some values into my table. Before doing

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.