Jump to content
Larry Ullman's Book Forums

Stick Forms Inside Php


Recommended Posts

having problem with sticky forms inside php:

 

inside html tags:

<form action="" method="post">

<p>Lastname:<input type="text" name="last_name" size="20" maxlength="20"

value="<?php if (isset($_POST['last_name']))

echo $_POST['last_name']; ?>" /></p>

</form>

 

inside php: ---> what is the correct syntax

<?php

echo '<form action="" method="post">

<p>Lastname:<input type="text" name="last_name" size="20" maxlength="20"

value="php code here???" /></p>';

 

?>

Link to comment
Share on other sites

You'll have to use concatenation to use PHP functions within a string echoed by PHP:

<?php
echo '<form action="" method="post">
<p>Lastname:<input type="text" name="last_name" size="20" maxlength="20"
value="' . (isset ($_POST['last_name']) ? $_POST['last_name'] : '') . '" /></p>';

?>

Link to comment
Share on other sites

 Share

×
×
  • Create New...