Freedom1 Posted August 24, 2010 Report Share Posted August 24, 2010 How about making a video showing an example of using php with a contact form that is already in a website template? I won't be creating many forms from scratch, since I plan to use ready made website templates, but I'm having trouble deciphering just how to incorporate php into an existing form to make it work. One example would be helpful. Thanks. Quote Link to comment Share on other sites More sharing options...
Wickham Posted August 25, 2010 Report Share Posted August 25, 2010 There are two videos here:- http://www.killersites.com/university/ under Beginners PHP - Processing Forms with PHP You don't have to edit the html form at all except to change the action to a php url to process the form, like <form method="post" action="sendmail.php"> The form input tags should already have name="...". All you need to add is the separate php processing file. You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension. See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from http://www.jemjabella.co.uk/php-scripts-php-mail-form http://www.formmail.com/ http://www.email-form.com/ Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 26, 2010 Author Report Share Posted August 26, 2010 There are two videos here:- http://www.killersites.com/university/ under Beginners PHP - Processing Forms with PHP You don't have to edit the html form at all except to change the action to a php url to process the form, like <form method="post" action="sendmail.php"> The form input tags should already have name="...". All you need to add is the separate php processing file. You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension. See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from http://www.jemjabella.co.uk/php-scripts-php-mail-form http://www.formmail.com/ http://www.email-form.com/ Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 26, 2010 Author Report Share Posted August 26, 2010 Thanks, I've been trying to do as you suggested, but I'm sure it's something I am not getting right with the code. I'll keep hacking away at it. I should learn a lot about this by the trial and error method! Quote Link to comment Share on other sites More sharing options...
falkencreative Posted August 26, 2010 Report Share Posted August 26, 2010 Thought I'd also mention in case it's useful -- I did a 6 part series on form validation with PHP and Javascript. It covers how to create a PHP/Javascript validated contact form, and hopefully should be easy for beginners to follow. It's available in the KS University (http://www.killersites.com/university/) under PHP > Form Validation with PHP & Javascript. Also, if you're having coding issues, feel free to post if you have trouble solving issues on your own. Sometimes a fresh set of eyes really helps. Quote Link to comment Share on other sites More sharing options...
Wickham Posted August 26, 2010 Report Share Posted August 26, 2010 How are you trying to process the PHP? You can't process PHP on your computer from a local php file unless you have a server (WampServer 2 or XAMPP) on your PC which incorporates Apache. You then put all the files into a special folder which the local server operates (C:\wamp\www folder for WampServer). If you have uploaded your php file to your host and it still doesn't work online, does your hosting service support PHP? Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 27, 2010 Author Report Share Posted August 27, 2010 How are you trying to process the PHP? You can't process PHP on your computer from a local php file unless you have a server (WampServer 2 or XAMPP) on your PC which incorporates Apache. You then put all the files into a special folder which the local server operates (C:\wamp\www folder for WampServer). If you have uploaded your php file to your host and it still doesn't work online, does your hosting service support PHP? Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 27, 2010 Author Report Share Posted August 27, 2010 I've started my own web hosting company so I have my own server, that is I pay for the space. I've uploaded the PHP file to a subdomain I created for the website. Thanks for thinking about it though. Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 28, 2010 Author Report Share Posted August 28, 2010 There are two videos here:- http://www.killersites.com/university/ under Beginners PHP - Processing Forms with PHP You don't have to edit the html form at all except to change the action to a php url to process the form, like <form method="post" action="sendmail.php"> The form input tags should already have name="...". All you need to add is the separate php processing file. You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension. See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from http://www.jemjabella.co.uk/php-scripts-php-mail-form http://www.formmail.com/ http://www.email-form.com/ Quote Link to comment Share on other sites More sharing options...
Freedom1 Posted August 28, 2010 Author Report Share Posted August 28, 2010 I fear I may have led you down the garden path. The form is actually Javascript. Here is the html. There is no "action" tag. Is this form poorly coded then, or more sophisticated than the usual? <div class="container1"> <div class="col-5"> <div class="h3"><input type="text" onblur="if(this.value=='') this.value='Name:'" onfocus="if(this.value =='Name:' ) this.value=''" value="Name" /></div> <div class="h3"><input type="text" onblur="if(this.value=='') this.value='E-mail:'" onfocus="if(this.value =='E-mail:' ) this.value=''" value="Email" /></div> <div class="h3"><input type="text" onblur="if(this.value=='') this.value='Phn:'" onfocus="if(this.value =='FAX:' ) this.value=''" value="Phn" /></div> </div> <div class="col-6"> <textarea rows="40" cols="30" onblur="if(this.value=='') this.value='Message:'" onfocus="if(this.value =='Message:' ) this.value=''" >Message</textarea> </div> <br class="clear" /> </div> </div> </div> <br class="clear" /> </div> </div> </div> </div> </div> <div class="left-bottom-corner png"> <div class="right-bottom-corner png"> <div class="border-bottom png"><div class="pa indent4"></div><div class="container"><a href="#" class="link-2" onclick="document.getElementById('form').submit()"><em><b>Submit</b></em></a></div></div> </div> </div> </div> </div> </form> </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.