Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Form Fields

Status
Not open for further replies.

Ivan1

Programmer
Jun 18, 2001
113
0
0
US
Hello.
I'm trying to figure out how to make sure that visitors to a Web page containing a form cannot submit the form without filling in the necessary fields. Any suggestions are much appreciated.
Ivan
 
This is an extremely vague and general question. This involves both javascript as well as PHP (or any server-side language for that matter).

Since this is such a widely open-ended question I can only suggest to google undere the terms 'php server side validation' or something similiar and start there.

If you have more specific questions, then post them here.
 
This is something that I have:

<?php
if($_POST[submit]){ //when submit button is hit

if (($_POST[var1] == "") || ($_POST[var2] == "")
{
?>
<SCRIPT LANGUAGE="JavaScript">location.replace('<?php
more php code here

Here I am checking, when the submit button is hit, if the fields var1 and var2 are empty. If they are then , using javascript, I am redirecting to a page using information is missing.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top