LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to intersperse PHP with HTML again (https://www.linuxquestions.org/questions/programming-9/how-to-intersperse-php-with-html-again-833553/)

resetreset 09-21-2010 08:51 AM

How to intersperse PHP with HTML again
 
Hi,
In my site, I have a "Make A Friend" link, which will lead to a page where the user has to input their username and password, to identify who they are. The link is like so: "makeafriendlogin.php?person=26", to identify the person who is going to *making* the friend. When the Submit button on the login page is clicked, the "person" argument has to be transmitted to the script that handles it (makefriend.php). This is how I'm going to lay out the "makeafriendlogin.php" script:

<form method="post" action="makefriend.php">
<input name="username" type="text>
<input name="password" type="password">
<?php
$person=$_POST['person'];
<input name="author" type="hidden" value="$person">
?>
<input type="submit" value="submit">
</form>




My probem is with the "<input name="author" type="hidden" value="$author">" line - unless I put it within <?php and ?> tags, the "$person" won't be parsed, but at the same time, it's HTML, not PHP.... so I can't figure out what to do. Should I put it in a "print" statement?

Can anyone help?


Apologies if it sounds like another thread of mine on the same topic, but I'm really getting confused about *this matter*.

Thanks.

alunduil 09-21-2010 08:55 AM

You are correct. The best way to handle that line is simply:

Code:

<input name="author" type="hidden" value="<?php echo $author; ?>">
Regards,

Alunduil


All times are GMT -5. The time now is 05:19 PM.