0

I'm trying to this syntax, but it's not working....

echo' < input type="text" class="form-control" id="state" name="state" placeholder="Enter States" value=" < ?php echo $_POST['state']; ?>"> '; 

It's show error message:

Parse error: syntax error, unexpected 'state' (T_STRING), expecting ',' or ';'.

How can I resolve this error. Please help me for the same.

Thanks in Advance Guys!

Narendra Jadhav
  • 10,052
  • 15
  • 33
  • 44
Piyush Kukadiya
  • 67
  • 1
  • 2
  • 7

2 Answers2

0

this is wrong: echo'hello';

this is right: echo('hello'); // best way imho

this is right: echo 'right';

Your code could look like this:

echo ('<input type="text" class="form-control" id="state" name="state" placeholder="Enter States" value="' . $_POST['state'] . '">');

The code above works, but if the user enters special characters it can break the HTML of your site (and mean a security issue). So you should use this:

echo ('<input type="text" class="form-control" id="state" name="state" placeholder="Enter States" value="' . htmlentities($_POST['state']) . '">');
ESP32
  • 8,089
  • 2
  • 40
  • 61
-1

Replace your code with this code:

echo "<input type='text' class='form-control' id='state' name='state' placeholder='Enter States' value='<?php echo $_POST["state"]; ?>'>";
webdev
  • 47
  • 6