Sowing the seeds of your business growth

my first php code


08.12.08 Posted in Uncategorized by Kimberly

 my first php code

A friend told me  along time ago told me I should have been a programmer.  PHP is a code I’ve always wanted to learn. What better way then to configure simple but functional forms!!  From what I’ve read not only was it easy once you learned the foundation of sendmail.php but also the responses are also customizable as they can be embedded in HTML.  With the help of a fellow programmer,  I figured out how to write my first sendmail.php.

Writing the feedback form:

In the <body></body> area of your HTML, create a form with various lables. Make sure you write down what lables IDs you assign to each field.

<body>
<form id=”form” name=”form” method=”post” action=”sendmail.php”>
<label>Name <input type=”text” name=”Name” id=”Name” /> </label>
<label>Email <input type=”text” name=”Email” id=”Email” /> </label>
<label>Message <textarea name=”Message” id=”Message” cols=”45″ rows=”5″></textarea>
</label>
</form>
</body>

Writing the PHP Code

Create a file called sendmail.php code and insert the code. For any field rename as follows

$fieldname = $_POST['Fieldname];

Little did I know too, you need to add a dot (.) when adding the field variable in HTML. Thank god for my programmer friend!

‘.$Fieldname.’

<?php// fields
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Message = $_POST['Message'];// message in HTML
$message =’
<HTML>
<head>
<title>FORM TITLE RESPONSE</title>
</head>
<body>
<p><strong>General Information</strong></p>
<p>Full Name: ‘.$Name.’ </p>
<p>Email: ‘.$Email.’  </p>
<p>Message:’.$Message.’  </p>
</body>
</html>’;
//send mail code
mail(“yourname@yourwebsite.com”,”Subject of Email”,$message,”From:yourname@yourwebsite.com”.
//HTML Required code for header
“MIME-Version: 1.0n”.
“Content-type: text/html; charset=iso-8859-1″);
//redirect to
header( “Location: http://yourwebsite.com/thankyou.html”);

After much trial and error, I finally was able to create the exact form I wanted. Now I can create more forms and surveys that are fully customized towards my clients and my needs.




Leave a Reply