Jump to content

How to change name


dudejma

Recommended Posts

This part of my coding, I got from a pre-written snippet. It works!.. Except for two things.. That I can think of right now. Haha. One: I'm wondering how to change the error message to say what I want the field name to be called instead of it's actual name in the form, and how can I get it to save everything that the user already put into the field?

 

$allowedFields = array(
    	'fname',
    	'lname',
    	'email',
'password',
   	'country',
'vatsim',
'birthMonth',
'birthDay',
'birthYear',
'hub',
'priorVA',
'rosterLink',
'priorPID',
'transferHours',
'agree',
);


$requiredFields = array(
'fname',
    	'lname',
    	'email',
'password',
    	'country',
'vatsim',
'birthMonth',
'birthDay',
'birthYear',
'hub',
'agree',
);


$errors = array();
foreach($_POST AS $key => $value)
{
    
    if(in_array($key, $allowedFields))
    {
        $$key = $value;

        
        if(in_array($key, $requiredFields) && $value == '')
        {
            $errors[] = "The field $key is required.";
        }
    }
}


if(count($errors) > 0)
{
    $errorString = '<font color="red"><p>There was an error processing the form.</font></p>';
    $errorString .= '<ul>';
    foreach($errors as $error)
    {
        $errorString .= "<li>$error</li>";
    }
    $errorString .= '</ul>';

    
    include 'join2.php';
}
else
{

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/240168-how-to-change-name/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.