Is it better to send an html form to a seperate page, or send it back to the same page??
i keep hearing to seperate logic from presentation, so I was wondering if I should seperate my forms from my form handlers as well.
As of now, Im doing this...
<?php
if(isset($_POST['submitted'])){
//Validate the form
if(empty($_POST['name'])){
$errors['name'] = 'Please enter your name';
}
//IF no errors INSERT INTO database and redirect
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" />
<?php if(isset($errors['name'])) echo '<span class="error">'.$errors['name'].'</span>'; ?>
<input type="submit" />
</form>
Is this good, or should I completely seperate the php from the form and just include one into the other... or something of the sort