Form Validation Feedback Problem

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Fri Jun 01, 2012 4:40 am

Sure.

You have form.html
and process.php

The form is displayed.
They fill out the form.
They submit the form, which goes to process.php


process.php takes all of the POST variables and checks them.
ie..
if (!isset($_POST['fullname'])) {
$error['fullname'] = "Full Name is required.";
} elseif (isset($_POST['fullname']) && $_POST['fullname'] != NULL || $_POST['fullname'] != '') {
$fullname = trim(mysql_real_escape_string(strip_tags($_POST['fullname'])));
} else {
$error['fullname'] = 'Full Name is required.";
}

.... do this for each one you want to check/clean..



if (isset($error)) {
include ('form.html');
die();
}





Your form.html should have traps to catch errors in it.. like so..

echo '
<form name="name" method="post" action="process.php">
<input type="text" name="fullname" value="'.@$fullname.'">'.((isset($error['fullname']) ? "$error[fullname]" : "").'<br />
</form>
';




Make sense?

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Jun 07, 2012 4:55 am

parse through your error log file, and see where it's breaking, one fix at a time.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest