I am having trouble getting my code check. I wrote a confirmation for the first name, last name and email address, however I do not know where to insert the command for the PHP code that will be called in my main html.
I thought I needed to add an action to the form:
<body>
<div class="logo"></div>
<div class="login-block">
<h1>Create Account</h1>
<form action="insert_data.php" method="post">
<form action="validate_data.php">
<input type="text" value="" placeholder="First Name" name="first_name" />
<input type="text" value="" placeholder="Last Name" name="last_name" />
<input type="email" value="" placeholder="E-mail Address" name="email_address" />
However, I do not know if this is correct. All three validation notes are saved in a file named validate_data.php.
My code for checking the name and surname is practically no different from the changes in the main "names":
<?php
$first_name = test_input($_POST["first_name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$first_name)) {
$first_nameErr = "Incorrect name format.";
}
?>
and for my letter:
<?php
$email_address = test_input($_POST["email_address"]);
if (!filter_var($email_address, FILTER_VALIDATE_EMAIL)) {
$email_addressErr = "Invalid email format.";
}
?>
Is there any specific place that I will need to name? Or am I just making some stupid mistake and skipping it?
source
share