Passing placeholder value to a variable

Asked

Viewed 277 times

0

Hi, I’m a newbie and would like to know how I can pass the value of the placeholder to a variable ($email)

<input type="text" class="form-control" placeholder="Email" = name=""/>
  • For example: You would like to save only the word "Email" ?

  • i would like to play what the user write in the Email field for within the variable $email

  • but why do you want to do this ?

  • i am trying to implement a system to recover the password, then in case I would play the value that the user passed to the variable and use it to give an update only in the email informed, I do not know if it was possible to understand

  • it is not better to define a name in this input and make $email = $_POST['input name'] ?

  • placeholder="Email" = name="" this does not exist.

  • Ahh then you want to retrieve the input text for php.. The placeholder is just a hint to show what the user should fill in

Show 2 more comments

1 answer

0

There are some ways you can pass on the value of your input.

As you’re new, I’ll show you a very simple way. The default

<form action="serarquivo.php" method="post">
    <label for="email">Email</label>
    <input type="email" placeholder="email" name="email">    
</form>

In his serarquivo.php you receive your variable according to the attribute name of your input

<?php
  $_email = $_POST['email'];
  echo "O e-mail recebido foi ".$_email; 
?>

There are some ways to submit from your form, which are:

  • GET: passes parameter by URL
  • POST: passes parameter in hidden form (not by URL)

Reference: https://www.tutorialspoint.com/php/php_get_post.htm

Browser other questions tagged

You are not signed in. Login or sign up in order to post.