1

So, I have a disabled email form field whose placeholder and value are retrieved from $_GET['email']:

<input name="email" type="text" placeholder="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" disabled>

When the user fills out the form, I was hoping that $_POST['email'] would have the email value, but it doesn't (it's empty). What am I missing/forgetting? Is there a clever way to pass this value along? Thanks!

Matt
  • 1,053
  • 4
  • 14
  • 29

6 Answers6

3

change attribute disabled to readonly because disabled not submit values..

<input name="email" type="text" placeholder="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" readonly>
Maxi Schvindt
  • 1,432
  • 1
  • 11
  • 20
3

As Cuchu stated, you could use readonly instead of disabled. Or you could duplicate the field and change the type to hidden.

<form method="post" action="register.php">
    <input type="text" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" disabled>
    <input name="email" type="hidden" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>">
</form>
Community
  • 1
  • 1
programmerKev
  • 399
  • 1
  • 3
  • 7
1

I think it is better to use the readonly attribute instead of disabling the input.

<input name="email" type="text" placeholder="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" readonly="readonly">
Aron
  • 129
  • 1
  • 3
  • 13
0

Placeholder is a prompt, not a value. If you want the textfield to have a value of the email, use the "value" attribute, not the "placeholder".

Ethan Brown
  • 683
  • 6
  • 11
0

You should enclose in a form tag and set the method to post as

<form action="" method="post">
<input name="email" type="text" placeholder="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>" disabled>
</form>
pritesh
  • 2,162
  • 18
  • 24
0
  //try this
<form method="post">
<input type="text" name="email"><input type="submit" value="click" name="btnClick" id="btnClick">
<input type="text" name="email1" placeholder="inserted value" value="<?php echo (isset($_POST['email']))? $_POST['email'] : "" ?> ">      
</form>
Tosif
  • 36
  • 5
  • " disabled="disabled"> you can disable it so it can b edited,,inserted value only can be seen or use read only attribute. – Tosif Apr 21 '16 at 03:11