# Form validation problem

**URL:** <https://forum.kirupa.com/t/form-validation-problem/255022>\
**Category:** programming\
**Created:** [March 18, 2008, 11:35am UTC](https://forum.kirupa.com/t/form-validation-problem/255022 "2008-03-18T11:35:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![almadera](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@almadera](https://forum.kirupa.com/u/almadera)\
**Post date:** [March 18, 2008, 11:35am UTC](https://forum.kirupa.com/t/form-validation-problem/255022/1 "2008-03-18T11:35:04Z")

</div>

I’m using Godaddy’s **gdform.php** form mailer for my forms. The forms work perfectly except the validation. I need the visitors to fill in the fields and then submit the information to my email, but the problem is that everyone can submit even if he doesn’t fill in the form. I want all of the fields to be required.

**Here is my form script :**

\<form action="/gdform.php" method=“post”\>  
\<table align=“center”\>

\<input type=“hidden” name=“subject” value=“Form Submission”\>  
\<input type=“hidden” name=“redirect” value="/Add/thankmes.html"\>  
\<input type=“hidden” name=“required” value=“YourName, Email, description”\>

\<tr\>  
\<td\>\<p\>\<font color=WHITE font size=4\>Your Name:\</p\> \</font\>\</td\> \<td align=center height=50\>\<p\>\<input type=“text” name=“YourName” size=“52”/\>\</p\>\</td\>  
\</tr\>

\<tr\>  
\<td\>\<p\>\<font color=WHITE font size=4\>Your E-mail:\</p\> \</font\>\</td\> \<td height=50\>\<p\>\<input type=“text” name=“Email” size=“52”/\>\</p\>\</td\>  
\</tr\>

\<tr\>  
\<td\>\<p\>\<font color=WHITE font size=4\>Your Message:\</p\> \</font\>\</td\> \<td\>\<br\>\<p\>\<textarea name=“description” cols=“40” rows=“5”\>  
\</textarea\>\</p\>\</td\>  
\</tr\>

\<tr\>  
\<td\>\<input type=“submit” name=“submit” value=“Send”/\>\</td\>  
\</tr\>

\</table\>  
\</form\>

**And here is the gdform.php script :**

\<?php  
$request\_method = $\_SERVER[“REQUEST\_METHOD”] ;  
if($request\_method == “GET”){  
$query\_vars = $\_GET;  
} elseif ($request\_method == “POST”){  
$query\_vars = $\_POST;  
}  
reset($query\_vars);  
$t = date(“U”);

$file = $_SERVER[‘DOCUMENT\_ROOT’] . "/…/data/gdform_" . $t;  
$fp = fopen($file,“w”);  
while (list ($key, $val) = each ($query\_vars)) {  
fputs($fp,"\<GDFORM\_VARIABLE NAME=$key START\>  
“);  
fputs($fp,”$val  
“);  
fputs($fp,”\<GDFORM\_VARIABLE NAME=$key END\>  
“);  
if ($key == “redirect”) { $landing\_page = $val;}  
}  
fclose($fp);  
if ($landing\_page != “”){  
header(“Location: http://”.$\_SERVER[“HTTP\_HOST”] .”/$landing\_page");  
} else {  
header(“Location: http://”.$\_SERVER[“HTTP\_HOST”] ."/");  
}

?\>

The user can fill in any, all, or none of the fields and submit. Does anyone know how to edit the **gdform.php** code so it doesn’t pass empty fields ?
