0

Note: email address structure is local-part@domain.

For example I am asking user to provide his email:

<label>Your Gmail:</label><input type="email" name="emailaddress"><label>@gmail.com</label>

But instead of letting him/her type the complete email address (e.g. user@gmail.com), I want to let user type only local-part without domain. But how can I send this email to MySql database now? Basically I need to append custom input to @gmail.com every time user submits the form. For example, records in my database would look like user1@gmail.com, user2@gmail.com etc.

Can anyone help?

tera_789
  • 489
  • 4
  • 20
  • It is not clear what you need. If you submit the form where this field is in, it will arrive at the server. Perhaps you need Ajax? – mplungjan Jul 09 '18 at 06:16
  • 1
    You'll have to put your MySQL insertion routine in your question so we can add in the appending of the string for you. Something like: `$email .= '@gmail.com';`. – KIKO Software Jul 09 '18 at 06:18
  • Please add sql code for insert opertaion. – Sinto Jul 09 '18 at 06:18
  • @KIKOSoftware I was thinking about doing it this way - basically concatenating strings. e.g. I have `$email = $_POST['email'];` and then I would `$email .= '@gmail.com';` I will try it and let you know. thanks – tera_789 Jul 09 '18 at 06:25
  • 2
    Possible duplicate of [PHP string concatenation](https://stackoverflow.com/questions/11441369/php-string-concatenation) – Roshana Pitigala Jul 09 '18 at 06:35

2 Answers2

1

In PHP build a String like this.

$email = $_REQUEST['emailaddress'];
echo "$email@gmail.com";

if the value submitted by the form was john.smith, the output would be

john.smith@gmail.com


Read PHP 5 Form Handling to understand how to retrieve the parameters parsed by the form.

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
0

Tried in my local works perfect.

$email = $_POST['email'] //Text box value
$email = $email."@gmail.com";

You are required to do some concatenation like above

Anand Huded
  • 641
  • 5
  • 12