Jump to content

Problem with my website form


SjCBalls

Recommended Posts

I have a registration for m on my website and it only sends me the required fields upon user submitting form, the optional fields, even when filled out does not get sent?  I do not know what I am doing wrong,  Can you please check this php file and see if there is an obvious error I cannot find?  Please help as I am completely new to this and am building the website for a community sports club in my free time.  I have attached the html page to this request in case it helps.  Thanks in advance

 

<?php





$myemail  = "info@gtta.gi";
$email_subject = "Registration Form";





$name       = check_input($_POST['name'], "Enter your Name");
$email      = check_input($_POST['email'], "Please Enter your Email");
$phone      = check_input($_POST['phone'], "Enter your contact number");
$text       = check_input($_POST['text']);
$gender     = check_input($_POST['gender']);
$do         = check_input($_POST['do']);
$address    = check_input($_POST['address']);
$played     = check_input($_POST['played']);




if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
    show_error("E-mail address not valid");}



$message = "Hello! The Registration form has been submitted by:


Name: $name 

E-mail: $email

Phone: $phone
DOB: $text
Gender: $gender
What they do: $do
Address: $address
Played?:  $played";




mail($myemail, $subject, $message);



header('Location: thanks.html');
exit();




function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}

function show_error($myError)
{
?>
    
<html>
    
<body>


<b>Please correct the following error:</b><br /><?php echo $myError; ?>

    
</body>
    
</html>

<?php
exit();
}
?>

registergtta.html

Link to comment
Share on other sites

On the dropdown the name attribute value is applied to the select element only, NOT! the options. The $_POST['nnn'] key or index name represented by 'nnn' must match the value of the name attribute.

<select class="form-control" name="Gender">

and

$_POST['gender']

are treated as different.

ALL form inputs, input select, textarea, radio, checkboxes must have a name attribute and value to be retrieved by $_POST[''].

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...