Good evening to all of you!

I was wondering if anyone would be willing to assist me in building an HTML feed back form powered by PHP. Quite frankly I don't care what its powered by as long as it work. Any suggestions???

Thanks for your support.

C-

I have made a standard email form and is below. The only thing you need to change is the variable $address (about line 4) to your real email address to receive website emails. Also this email form supports html formatting.

<?
if (isset($_POST['subject']) && $_POST['message']!=='')
    {
    $address = "your_real_email@domain.com"; //change this to the receiving address.
    $subject = "Website Email: ".$_POST['subject'];
    if ($_POST['name']!=='')
        {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."</td></tr></table>";
        } else {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
        "</td></tr></table>";
        }
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
 
    mail($address,$subject,$body,$headers);
    }
//below displays the form while above processes it.
echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
<textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
<input type='submit' value='submit'></form>";
?>

I have one follow-up question.
I have tinkered with this to try to add some fields and I can't seem to do it. I was wondering if you could assist me in adding some fields, in this order:
Name
Email Address
Birthday
Gender (Would it be possible to have a radio selection here?)
Finnally, I couldn't seem to edit the layout in Dreamweaver? Is there a specific way to do this? I would like to justify it and add some tables and text just to make it pretty. Thank you so much for your help!!! Take care!

Cort

Sorry about the late reply but this is the code that I have now made:

<?
if (isset($_POST['subject']) && $_POST['message']!=='')
    {
    $address = "your_real_email@domain.com"; //change this to the receiving address.
    $subject = "Website Email: ".$_POST['subject'];
    if ($_POST['name']!=='')
        {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
        .$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
        $_POST['gender']."<p>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."
<p>
Email: ".$_POST['email']."</td></tr></table>";
        } else {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
        .$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
        $_POST['gender']."<p>".$_POST['message']."<p>Email: ".$_POST['email']."</td></tr></table>";
        }
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
    mail($address,$subject,$body,$headers);
    }
//below displays the form while above processes it.
echo "<form method='post'><table border=0 cellpadding=0 cellspacing=0><tr><td>Subject:</td><td align=left colspan=1><input type=text value='' maxlength=100 name='subject' size=35></td></tr><tr><td>Email:</td><td align=left colspan=1><input type=text value='' name='email' size=35></td></tr><tr><td>Birthday:</td><td colspan=1 rowspan=2><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><select name='birthday' size=1>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select><select name='birthmonth' size=1>
<option value='January'>Jan</option>
<option value='February'>Feb</option>
<option value='March'>Mar</option>
<option value='April'>Apr</option>
<option value='May'>May</option>
<option value='June'>Jun</option>
<option value='July'>Jul</option>
<option value='August'>Aug</option>
<option value='September'>Sep</option>
<option value='October'>Oct</option>
<option value='November'>Nov</option>
<option value='December'>Dec</option>
</select><input size=7 maxlength=4 name='birthyear'></td></tr><tr><td>   Male:<input type='radio' name='gender' value='Male'></td><td align='right'>Female:<input type='radio' name='gender' value='Female'></td></tr></table></td></tr><tr><td>Gender:</td></tr><tr><td colspan=3><textarea cols=35 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name' size=28><input type='submit' value='submit'></td></tr></table></form>";
?>

Above is the form with the extra fields added. Also, as for your question about dreamweaver, perhaps dreamweaver is not php echo friendly. So place the below code into dreamweaver and after using dreamweaver, place dreamweavers contact form code within the last echo function of the code above. Also make sure the double quotation (") is not used within the dreamweaver code otherwise it will cause a php error. Instead use the single quotation (').

<form method='post'><table border=0 cellpadding=0 cellspacing=0><tr><td>Subject:</td><td align=left colspan=1><input type=text value='' maxlength=100 name='subject' size=35></td></tr><tr><td>Email:</td><td align=left colspan=1><input type=text value='' name='email' size=35></td></tr><tr><td>Birthday:</td><td colspan=1 rowspan=2><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><select name='birthday' size=1>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select><select name='birthmonth' size=1>
<option value='January'>Jan</option>
<option value='February'>Feb</option>
<option value='March'>Mar</option>
<option value='April'>Apr</option>
<option value='May'>May</option>
<option value='June'>Jun</option>
<option value='July'>Jul</option>
<option value='August'>Aug</option>
<option value='September'>Sep</option>
<option value='October'>Oct</option>
<option value='November'>Nov</option>
<option value='December'>Dec</option>
</select><input size=7 maxlength=4 name='birthyear'></td></tr><tr><td>   Male:<input type='radio' name='gender' value='Male'></td><td align='right'>Female:<input type='radio' name='gender' value='Female'></td></tr></table></td></tr><tr><td>Gender:</td></tr><tr><td colspan=3><textarea cols=35 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name' size=28><input type='submit' value='submit'></td></tr></table></form>

Hope that helps

Why dont you try it with a simple txt file. When user submit data then it will store in a txt file which keep in our server ..... safe and secure .....<EMAIL SNIPPED> for more details and code ....

Rajeesh,
Can you shed some light on your recommendation, I would like to learn more! Also what do you think of building a java script web form, these also seem fairly straight forward. Any ideas?

//write text.php
// Get the user details.
$getdate = date( 'd-m-Y, H:i:s' );// Get the date.
$user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP.just in case
$referer = getenv("HTTP_REFERER");// Get the refering page. just in case
// Look for the text file and open it for writting.
$file = "./logfiles/logfile.csv";// define the text file. Note I am using a .csv file, it is still text but opens in excell for manipulation when I remember to check it
$fp = fopen($file, "a+");//open the text file for writing.
// Write into the text file.
fputs ($fp, "$user_ip,$getdate, $referer, $data1, \n"); //$data1 can be any number of data fields required to match the form,
fclose($fp);// Close the text file.

The scrap above can be appended to any php form and write to the texfile as part of the php form processing, checking IP and referrer helps reduce obvious dodgy entries.
Javasript on the user side, and php at the server, is pretty much AJAX, and can do really impressive things, the form handlers you look for may be for download at hotscripts, sourceforge, javascript.net or one of the other script repositories If(!$referer==$_SERVER['php_self']) die('data must submitted from the online form'); just crossed my mind assuming this is a self processed form (action='<?php echo $_SERVER; ?>')

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.