| | |
PHP Feedback Form
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
php Syntax (Toggle Plain Text)
<? 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>"; ?>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Nov 2008
Posts: 4
Reputation:
Solved Threads: 0
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
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:
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 (').
Hope that helps
php Syntax (Toggle Plain Text)
<? 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>"; ?>
html Syntax (Toggle Plain Text)
<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>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
•
•
Join Date: Sep 2008
Posts: 138
Reputation:
Solved Threads: 0
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 ....
Last edited by peter_budo; Dec 13th, 2008 at 4:54 pm. Reason: Keep it On The Site - Do not post asking for an answer to be sent to you via email or PM.
php Syntax (Toggle Plain Text)
//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.
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['PHP_SELF']; ?>') Last edited by almostbob; Jan 11th, 2009 at 1:09 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
![]() |
Similar Threads
- FeedBack Form in php (PHP)
- Contact us form help (PHP)
- PHP Sendmail Tutorial (PHP)
- Generate Free Feedback Form (Existing Scripts)
- Learning PHP but problem with script (PHP)
- Not sending Feedback Form (PHP)
- Form not sending email (PHP)
Other Threads in the PHP Forum
- Previous Thread: WAP+php
- Next Thread: Different of www1 and www
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






