Log in

View Full Version : Print Simple User Input to Website



Fighterfox
11-27-2010, 11:53 PM
Very simple and basic code, but I need help. Suppose I have two input fields in a form with a submit button--one for the user's name, and one for the user's message. When the user clicks submit, I'd like the name and the message to be printed to the webpage. What PHP code(s) will get this done? I greatly appreciate any answers!!!

nicmo
11-27-2010, 11:59 PM
<?php

$username = $_REQUEST["username"];
$message = $_REQUEST["message"];


if (strlen($message) > 0 and strlen($username) > 0)
{
?>
Submited: <? echo $message ?> by <? echo $username ?>
<?
}

?>

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

<label>
<input type="text" name="username" id="username">
</label>
<label>
<input type="text" name="message" id="message">
</label>
<input type="submit" value="Submit" />

</form>