Page 1 of 1

Trouble with simple PHP

Posted: Thu Oct 22, 2009 9:11 am
by James Lowman
I am trying to learn PHP for a small program that will be used with the new Bridge. I have written this:

<html>
<head>
<title>Simple Test</tittle>
</head>
<body>
<form action="formtest.php" method="POST"
<p>Name:<br />
<input type="text" name="user"/></p>
<p>Message:<br />
<textarea name="message" rows="5" cols=40"></textarea></p>
<p>input type="submit" value="send"/></p>
</form>
</body>
</html>

FORMTEST.PHP

<? php
echo"<p>Welcome <b>".$_POST["user"]."</b>!</p>;
echo"<p>Your message is:<br /><b>".$_POST["message"]."</b></p>";
?>

And the output that I get is:

Welcome ".$_POST["user"]."!

?>

What have I done wrong??
Jamie Lowman

Posted: Thu Oct 22, 2009 9:20 am
by James Lowman
The code does not show up in Email but it is in Brforum.ADS.NET. Under Non-Br related

Posted: Thu Oct 22, 2009 9:35 am
by Chris Shields
Looks like your are just missing some quotes and some other small syntax issues. I made some corrections.

Code: Select all

<html>
    <head>
        <title>Simple Test</title>
    </head>
    <body>
        <form action="formtest.php" method="POST">
            <p>
                Name:
                <br/>
                <input type="text" name="user"/>
            </p>
            <p>
                Message:
                <br/>
                <textarea name="message" rows="5" cols=40>
                </textarea>
            </p>
            <p>
                <input type="submit" value="Submit..." />
            </p>
        </form>
    </body>
</html>
And the PHP

Code: Select all

<?php 
echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
echo "<p>Your message is:<br /><b>".$_POST["message"]."</b></p>";
?>
I use an IDE called Apatana for this stuff. It flags syntax mistakes immediately so you don't spend so much time hunting for missing semicolons and quotes.

Hope that helps.

-Chris