How to use ucfirst in the "name" of a PHP form?
I need to receive (yes or yes), the names and surnames with the first letter in upper case, and we know that today x those who complete their data in a web form from a mobile phone do not always "bother" to start their names and surnames in capital, and I want to to force it from PHP itself.
Where does ucfirst (only in "name") ...?
<?php
$nombre .= $_POST['nombre'];
$mail .= $_POST['email'];
$asunto .= $_POST['asunto'];
$mensaje .= $_POST['mensaje'];
$header .= 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";
$cuerpo_mensaje .= "Enviado por: " . $nombre . " \r\n";
$cuerpo_mensaje .= "E-Mail: " . $mail . " \r\n\r\n";
$cuerpo_mensaje .= "Asunto: " . $asunto . " \r\n\r\n";
$cuerpo_mensaje .= "" . $mensaje . " \r\n\r\n";
?>
I will explain some exemplary code, because PHP is not my thing ...
:(
==================================================
==================
EDITO (solution)
Who can I serve, guiding me? by @Lixus, I did it like this:
$cuerpo_mensaje .= "Enviado por: " . ucwords($nombre) . " \r\n";
And that was it. Now even if visitors to the site write their names in lowercase (it happens in + 50% of cases, despite the measures taken in the development and programming, because many mobile keyboards and tablets ignore automatic capitalize), from now on with a simple ucwords in $ name I am already receiving the information as I needed.
And if you want to force more:
<input id="nombre" type="text" name="nombre" class="capitales" required>
And in the CSS:
.capitales {text-transform: capitalize}
And automatically everything happens from this == > Juan Perez to this == > J uan P erez
Greetings
;)
---------