1

i just wanted to pass data from html to another php file through php post but getting error as:

Parse error: syntax error, unexpected '<' in D:\Hosting\10378233\html\shanfolder\fulltest\index.php on line 4

while the html code is :

<form action="index.php" method="post">
<div><label for="cardlink">Card Image Link:<input type="text" name="cardlink" id="cardlink" style="width: 602px; height: 25px" /></label></div><div><input type="submit" value="GO"/>
</div>
</form>

and php file index.php code is this :

<?php
$cardlink = $_POST['cardlink'];
<p>Card Image Link :</p>  <input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, 'UTF-8'); ?>" />
?>
Bora
  • 10,529
  • 5
  • 43
  • 73
Umair Shah
  • 13
  • 3

5 Answers5

3

You are mixing the PHP and HTML syntax together which is wrong.

To add the HTML code you must end the PHP code with ?> delimiters.

Or you can add HTML code into PHP code using echo statement.

Example for both.

PHP

<?php
    $cardlink = $_POST['cardlink'];

    echo '<p>Card Image Link :</p>
    <input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, "UTF-8"); ?>" />';
?>

HTML

<?php
    $cardlink = $_POST['cardlink'];
?>
<p>Card Image Link :</p>
<input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, "UTF-8"); ?>" />
Bora
  • 10,529
  • 5
  • 43
  • 73
Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90
0

Just close <?php tag like this

<?php
$firstname = $_POST['cardlink'];
?>
<p>Card Image Link :</p>  <input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, 'UTF-8'); ?>" />
?>($feed);

Illustration:

$firstname = $_POST['cardlink'];
    ?>
    ^^
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0

Try below code, you didn't close you <?php ?> block

<?php
$firstname = $_POST['cardlink'];
?>
<p>Card Image Link :</p>  <input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, 'UTF-8'); ?>" />
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
0

You are opening php tags inside of opened php tags. Try this

<?php
$firstname = $_POST['cardlink'];
?>
<p>Card Image Link :</p>  <input type="text" value="<?php echo htmlspecialchars($cardlink, ENT_QUOTES, 'UTF-8'); ?>" />
Alex
  • 1,336
  • 10
  • 19
0

In the index.php you should print that HTML code, you shouldn't just put in there. Either print it, or just close the php code before the html code.

Mihaela
  • 109
  • 2