Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
theo

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>';

 

?>

Share this post


Link to post
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>';

?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...