11 Replies Latest reply: May 21, 2013 6:37 AM by vikki1987 RSS

    Some help with PHP and forms!

    vikki1987 Community Member

      Hi there,

       

      I have built a basic form in Dreamweaver (full code below) and i need the form details (once filled out) to be sent to a specified email address, the host server i use is 000webhost and they support PHP so no problems there. But, i am having majour problems writing the code as i don't have much knowledge of PHP, only HTML and CSS.

      I've looked online and have found some generic PHP form code but none of them work (even after making the relevant changes). I did notice that all the 'borrowed' PHP scripts were working fine with a form that was written in HTML as opposed to one built in Dreamweaver.

      Can anyone give me an insight to writing the correct code, the code i have tried so far is:

       

      <?php

         $name = $_REQUEST['name'];

        $email = $_REQUEST['email'] ;

        $message = $_REQUEST['message'] ;

       

        mail( "yourname@example.com", "Feedback Form Results",

          $message, "From: $email" );

        header( "Location: http://www.example.com/thankyou.html" );

      ?>

       

      But it does nothing. Also could someone explain the Name and ID pop up that comes up when creating a form in Dreaweaver, is it essential to fill out both fields?

       

      Many thanks and my HTML form code is below!

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>Untitled Document</title>

      </head>

       

       

      <body>

      <form id="form1" name="form1" method="post" action="">

        <p>

          <label for="Name">Name</label>

        </p>

        <p>

          <input type="text" name="Name" id="Name" />

        </p>

        <p>

          <label for="Email">Email</label>

        </p>

        <p>

          <input type="text" name="Email" id="Email" />

        </p>

        <p>

          <label for="Message">Message</label>

        </p>

        <p>

          <textarea name="Message" id="Message" cols="45" rows="5"></textarea>

        </p>

        <p>

          <input type="submit" name="Sumbit" id="Sumbit" value="Submit" />

        </p>

      </form>

      </body>

      </html>