form processing
Posted: Sat Jul 12, 2008 2:25 am
Hi everyone, I have a registration script process_form.php which
processes the user inputs of the form in main.htm. But i run
this script and click on the submit button, i get an error which
says- "Invalid argument supplied for foreach() in
C:\wamp\www\test\process_form.php
processes the user inputs of the form in main.htm. But i run
this script and click on the submit button, i get an error which
says- "Invalid argument supplied for foreach() in
C:\wamp\www\test\process_form.php
Code: Select all
************** process_form.php ********************
<?php
if(!filled_out($HTTP_POST_VARS))
{
echo "You have not filled the form out correctly - pleas";
exit;
}
function filled_out($form_vars)
{
// test that each variable has a value
foreach ($form_vars as $key => $value)
{
if(!isset($key) || ($value == NULL))
return false;
}
// return true;
}
?>
************************************************************
************************ main.htm **************************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Email</title>
</head>
<body>
<table style="width: 100%">
<tr>
<td style="width: 322px" valign="top">Email</td>
<td rowspan="4" valign="top">
<form method="post" action="process_form.php">
<input type="text" name="email"/><br/><br />
<input type="text" name="user"/><br /><br />
<input type="password" name="pass"/><br /><br />
<input type="password" name="pass2"/><br /><br
/>
<input type="submit" value="submit"/></form>
</td>
</tr>
<tr>
<td style="width: 322px; height: 20px;"
valign="top">username</td>
</tr>
<tr>
<td style="width: 322px; height: 13px;"
valign="top">password</td>
</tr>
<tr>
<td style="width: 322px"
valign="top">confirm</td>
</tr>
</table>
</body>
</html>