I am a new programmer and I tried a bunch of different ways to validate my code and clearly am doing it totally wrong. Any help would be appreciated. I am still working on validating just the name. This version clearly doesn’t make sense but i couldn’t get it to work any way I try.
<?php
require_once ('includes/classes/database.php');
require_once('includes/classes/user.php');
require_once('includes/header.php');
// if user submits a new registration
if (isset($_POST['name'],$_POST['email'],$_POST['pwd'],$_POST['pwd2']))
{
if(strlen(trim($_POST['name'])) <= 20)
{
return (true);
return $name;
}
else
{
return (false);
}
// validate input fields
//$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['pwd'];
$password2 = $_POST['pwd2'];
// if error fall through and redisplay page with errors
// if no errors update database and redirect to homepage
if ($uc->add_member($name, $email, $password) === FALSE)
{
echo "System Error. damn if I know what to do";
}
else
{
header("location: homepage.php");
}
}
?>
Just get the return name out. Then it will work.