Validate student number input


I’m reading this page trying to figure out how to validate the first input in my form.

My form opening looks like this:

<form action="thankyouBE17W9.php" method="POST" name="myForm" onsubmit="return checkForExpiration();" >

and the textbox is:

<p> <h3> Please insert your student number here: </h3> <INPUT TYPE="Text" NAME="sn" maxlength="10" size="10"> </p>

I’m getting some emails without a student number in the Subject line. They forget to enter their student number.

The student number is 10 digits, like: 1725010555

The name of the input box is “sn”, and they cannot insert more than 10 characters.
I don’t really need to check for empty, I just need a check like:

if len(sn) < 10:

go back and do it again

How do I, a layman, do that in php?

Also, if there is a problem, I think I need something like:

header(“Location: 17BEwWeek9HVv1.html”);

to send them back to the page. Would that work? Or do I need the complete path??

Thanks for any links, tips, advice!


To start with add validation on the front end too, so they aren’t submitting the form more than required.

<input type="phone" name="sn" pattern="\d{10}">


Thank you very much! Works like a charm! Even better: it is very simple, for a simple man like me!

Should I put SOLVED somewhere??