DenCowboy DenCowboy - 5 months ago 28
PHP Question

HTML form not submitting long string

I have an easy HTML form

<form method="post" action="process.php">
<label>First Name</label>
<input type="text" name="first_name" />
<br />
<label>Last Name</label>
<input type="text" name="last_name" />
<br />
<label>Department</label>
<input type="text" name="department" />
<br />
<label>Email</label>
<input type="text" name="email" />

<br />
<input type="submit" value="Add Employee">
</form>


When I click submit this will write the input to the DB.
I was always testing with very short names (a few letters). It works so now I tried some longer strings and it fails. I don't see an error but no data is written to my DB.

I can write 25 characters inside the box. So everything till 25 chars is inside the DB, all what is longer isn't.

Answer Source

This is not a HTML problem, as HTML does not behave like that (well, unless you use maxlength for the input).

This has to be a database issue. Your table probally has a VARCHAR(25) in it's structure. When you enter a longer string than it can contain, it truncates the remainder of the string. Thats why you do see the first 25 chars.

You can check this via your database management, like PHPmyAdmin. Go to the matching table, click 'structure'. You can also edit it here to a more appropriate length.