|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 7
|
|
| Author |
|
|
Advanced Member Joined: Sep 21, 2005 Post Count: 221 Status: Offline |
Hi, I am trying to understand how PHP works using contact form but there is one question I need to ask, do you need a contact form on a HTML page and create another page for PHP or could you combine both into one ? Please advice Thanks Gareth |
||
|
|
Advanced Member Joined: Jun 14, 2003 Post Count: 2940 Status: Offline |
You can combine them into one but that should only be done with the simplest of projects - it is considered bad design because you are mixing php code with HTML ... something you want to minimize. Have you seen my php video tutorials ? ---------------------------------------- Stefan Mischook Video Tutorial Store | Web Templates |
||
|
|
Advanced Member USA Joined: Mar 24, 2005 Post Count: 3000 Status: Offline |
I strongly suggest a separate mail form script. Your html contact form is going to send a "post" request the php form to process the form, make it email ready and fire it off. The process form will contain your email address. If your email address is on the same page as your html form, spambots will find it and send you spam. The email address will be tainted forever. spambots (last I knew) do not follow a form "post" and as a result your email address is protected. See the post, email protection for more info. ------------------------------------------------------------------ John D. Beatrice MaineWebworks "If you don't know where you are going, any road will get you there." - Lewis Carroll. "The art of life lies in a constant readjustment to our surroundings." - Okakura Kakuzo ---------------------------------------- "The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo Save the developers<!> Maine Webworks |
||
|
|
Advanced Member Joined: Sep 21, 2005 Post Count: 221 Status: Offline |
Ok, I read Web Designer magazine every month and saw a tutorial on (issue 119 page 43) how to build an email response form for my website and use both HTML and PHP into one page and the input fields are Name, Email, Comments, Checkbox and Submit. Is this a simple project and wise ? Another question, I have downloaded formmail and I am really confuse there are 3 PHP pages, form.php, form2.php and formmailer.php but none are HTML page ? So you strongly suggest 2 pages one is HTML and the other is PHP ? Please advice Thx Gareth |
||
|
|
Advanced Member Joined: Sep 3, 2005 Post Count: 2206 Status: Offline |
Form.php and form2.php are examples of forms. They are written in html, even though the pages are saved with a php extension. Because they contain no php code they could also use an html extension. Formailer.php contains the code that processes the information a user inputs into the form. It is written in php and must have the php extension to work. Write the html code for your from using the examples that come with frommailer if you wish. That can either be saved as an html page or php page. The critical pieces of information are the method and action attributes in the form tag and the hidden input field that contains the name config and value 0. The rest is up to you depending on what input fields you want to include. In the docs folder that comes with formmailer is an index.html page that contains instructions for configuring formailer.php to work with your form. the basic configuration is quite simple, 4 steps. Yes it is better to seperate the code that processes the form from the form itself for security reasons. No one can access your email if it is on a seperate page. You can write your own php code from scratch to process a form, it's a great way to learn and understand what the code is doing. But formmailer is just one of many scripts available that has been written, tested, and debugged, checks that any required fields have been filled in properly, and there's nothing that will compromise security. ---------------------------------------- Quiquid latine dictum sit altum viditur ---------------------------------------- [Edit 1 times, last edit by billyboy at Oct 20, 2006 6:37:13 AM] |
||
|
|
Advanced Member Joined: Sep 21, 2005 Post Count: 221 Status: Offline |
Hi, I have created 2 very simple pages one is form.htm and other is contact.php and want to test to see if the email was sent out successfully and to see if I receive it on Microsoft Outlook. Here is the form.htm code.. <form id="form1" name="form1" method="post" action="contact.php"> Email: <label for="email"></label> <input type="text" name="email" id="email" /> <div>Message: <label for="message"></label> <input type="text" name="message" id="message" /> <div> <input type="submit" name="Submit" value="Submit" /> </div> </div> </form> and the contact.php code.. <?php $to="support@pcglow.co.uk"; $subject="contact us"; $email=$_REQUEST['email']; $message=$_REQUEST['message']; $sent=mail($to,$subject,$message,$headers); if($sent) {print"your mail was sent successfully";} else{print"we encountered an error sending your mail";} ?> when I preview the form.htm on browser page and a dialogue box came up which says 'do you want to open or save this file' , am I going the right way, should I set up the testing server ? I have already installed xampp on my desktop which is up and running. I really want to test to see if this works before I add more codes into php page. Pls advice. Gareth |
||
|
|
Advanced Member USA Joined: Mar 24, 2005 Post Count: 3000 Status: Offline |
do you want to open or save this file' This is the usual response if the browser (probably IE) doesn't know how to process a file that is loaded into it. In other words, it sounds like the work you are doing is not located inside your local server's htdocs root directory. Php has to be parsed by the server to show inside a browser. I think the best thing to do is to read through the documentation provided for the customizing the apache server. It is a file called httpd.conf. The reason I suggest this is because you then assign different locations on your PC to be virtual server directories. For example, if you usually use My Documents to store your web projects, you can make My Docs a web directory and not have to move everything to the public_http directory. ---------------------------------------- "The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo Save the developers<!> Maine Webworks |
||
|
|
|
|
|
Current timezone is GMT Sep 5, 2010 10:27:45 PM |