AnsweredAssumed Answered

Can a personal web page include simple PHP?

Question asked by mmurnane on Aug 19, 2014
Latest reply on Aug 20, 2014 by kevinds

Can a personal web page include simple PHP?


I would like to have a contact form ... for example:

<?php

$action=$_REQUEST['action'];

if ($action=="")    /* display the contact form */

    {

    ?>

    <form  action="" method="POST" enctype="multipart/form-data">

    <input type="hidden" name="action" value="submit">

    <p>Your name:<br>

    <input name="name" type="text" value="" size="50"/><br>

    <p>Your email:<br>

    <input name="email" type="text" value="" size="50"/><br>

    <p>Message:<br>

    <textarea name="message" rows="10" cols="50"></textarea><br>

    <input type="submit" value="Send email"/>

    </form>

    <?php

    }

else                /* send the submitted data */

    {

    $name=$_REQUEST['name'];

    $email=$_REQUEST['email'];

    $message=$_REQUEST['message'];

    if (($name=="")||($email=="")||($message==""))

        {

        echo "All fields are required, please fill<a href=\"\">the form</a> again.";

        }

    else{       

        $from="From: $name<$email>\r\nReturn-path: $email";

        $subject="Personal Web Site Contact";

        mail("mikemurnane@shaw.ca", $subject, $message, $from);

        echo "Email sent!";

        }

    } 

?>


Outcomes