Hi im still having trouble with my coding. Just cant seem to get it to work and im totally confused.
The following code is fine and i want to keep it(this code checks for errors):
<?php
include("misc.inc.php");
foreach($_POST as $item => $value)
{
if ($item != "camera")
{
if ($value == "")
{
$blanks[] = $item;
}
}
}
if(isset($blanks))
{
$message_new = "The following fields are blank. Please enter the required information: ";
foreach($blanks as $value)
{
$message_new .= "$value, ";
}
extract($_POST);
include("signup_form.inc.php");
exit();
}
foreach($_POST as $item => $value)
{
if(!empty($value))
{
if(eregi("name",$item) or eregi("intro",$item))
{
if(!ereg("^[A-Za-z0-9.,' -]{1,50}$",$value))
{
$errors[] = "$value is not a valid entry.";
}
}
if(eregi("email",$item))
{
if(!ereg("^.+@.+\\..+$",$value))
{
$errors[] = "$value is not a valid email address.";
}
}
}
}
if(@is_array($errors))
{
$message_new = "";
foreach($errors as $value)
{
$message_new .= $value." Please try again<br />";
}
extract($_POST);
include("signup_form.inc.php");
exit();
}
Also here is my code for the signup form:
<body>
<form action="signup.php" method="POST">
<table border="0" width="100%">
<?php
if (isset($message_new))
{
echo "<tr><td style='color: red; font-weight: bold' colspan='2'>
<p>$message_new</p></td></tr>";
}
?>
<tr><td class="bold_right">First Name</td>
<td><input type="text" name="f_name"
value="<?php echo @$f_name ?>"
size="20" maxlength="20" /></td></tr>
<tr><td class="bold_right">Last Name</td>
<td><input type="text" name="l_name"
value="<?php echo @$l_name ?>"
size="20" maxlength="20" /></td></tr>
<tr><td class="bold_right">Camera</td>
<td><input type="text" name="camera"
value="<?php echo @$camera ?>"
size="30" maxlength="30" /></td></tr>
<tr><td class="bold_right">Field</td>
<td><select name = "field">
<?php
$FieldName= getField();
for ($n=1;$n<=5;$n++)
{
$field = $FieldName[$n];
echo "<option value='$field'";
if ($field== "Other")
echo " selected";
echo ">$field\n";
}
?>
</select>
</td></tr>
<tr><td class="bold_right">Introduction</td>
<td><input type="text" name="intro"
value="<?php echo @$intro ?>"
size="40" maxlength="150" /></td></tr>
<tr><td class="bold_right">Email</td>
<td><input type="text" name="email"
value="<?php echo @$email ?>"
size="20" maxlength="20" /></td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td class="bold_right">Login Name</td>
<td><input type="text" name="loginName"
value="<?php echo @$loginName ?>"
size="20" maxlength="20" /></td></tr>
<tr><td class="bold_right">Password</td>
<td><input type="text" name="password"
value="<?php echo @$password ?>"
size="20" maxlength="255" /></td></tr>
<input type="hidden" name="do" value="new">
<tr><td> </td></tr>
<tr>
<td style="text-align: center">
<input type="submit"
value="submit"></td>
</tr>
</table>
</form>
</body>
Now all I want to do is insert the given information into the database table which is shown below:
Field Type Null Key Default
picture varchar(60) YES NULL
member_id int(10) unsigned NO PRI NULL
f_name varchar(20) YES NULL
l_name varchar(20) YES NULL
field varchar(20) YES NULL
camera varchar(30) YES NULL
intro varchar(150) YES NULL
email varchar(60) YES NULL
loginName varchar(20) NO NULL
createDate date NO NULL
password varchar(255) NO NULL
If anyone can give me a solution for this code i would be sooo happy. Sorry to do this, it is a last reort.
Thanx.