Hi, I'm new to the forum and new to the php world.
My boss asked me if I could add a Mail feature to our Contact page (coded in HTML)
He gave me the FTP connection, I downloaded the "public_html" folder and found my first problem... I don't know which IDE I should open the project with (I usually use Eclipse for my Java projects).
1- What IDE should I use? I downloaded Dreamweaver but I don't know if that's the right one.
So I started looking at the code, and as of now it looks like this (CONTACT.HTML):
Your HTML is wrong. Your form element had no closing tag, neither did the fieldset or the container div. I've taken the liberty of correcting the errors and your code worked in my test:
With respect to the editor best suited to PHP, that's entirely at your discretion. I use Notepad++ to write all my code in, but some people use plain old notepad. Dreamweaver is an option, but it's not a good IDE in my opinion. It has a heavy, sluggish feeling to me and it also has annoying features that bug me such as auto code completion (which I know can be switched off) and annoying pop-up boxes that get right in the way of your code as your writing it. Dreamweaver is more of a designers tool to knock up websites without having to know too much about HTML/CSS.
Hi, thanks for your reply, I'll try to edit and add code tags right away.
The form, fieldset and div are closed on the html I posted. I received the mail you sent, can you tell me what else may be wrong?
This is where I close the tags:
HTML Code:
</fieldset></form><br class="clear" /><span class="error" id="name_error">Please input your name !</span><span class="error" id="email_error">Please input your mail !</span><span class="error" id="email_error2">Please use a valid !</span><span class="error" id="msg_error">Por Favor completa tu mensaje !</span></div>
This is my HTML head, do I have to include something else for the function to work?
HTML Code:
<head><link rel="shortcut icon" href="images/icono.jpg" /><meta charset="utf-8" /><title>Opticom</title><link href="styles/reset.css" type="text/css" rel="stylesheet" /><link href="styles/style.css" type="text/css" rel="stylesheet" /><link href="styles/inner.css" rel="stylesheet" type="text/css" /><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><!-- ////////////////////////////////// --><!-- // Javascript Files // --><!-- ////////////////////////////////// --><script type="text/javascript" src="js/jquery-1.6.4.min.js"></script><script type="text/javascript" src="js/hoverIntent.js"></script><script type="text/javascript" src="js/superfish.js"></script><script type="text/javascript" src="js/supersubs.js"></script><script type="text/javascript" src="js/contact.js"></script><script type="text/javascript" src="js/process.php"></script><script type="text/javascript">
jQuery(document).ready(function(){
//=================================== MAIN MENU ===================================//
jQuery("ul.sf-menu").supersubs({
minWidth : 12, // requires em unit.
maxWidth : 14, // requires em unit.
extraWidth : 3 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
// due to slight rounding differences and font-family
}).superfish(); // call supersubs first, then superfish, so that subs are
// not display:none when measuring. Call before initialising
// containing tabs for same reason.
});
</script></head>
Sorry about that. I was in a rush to leave for work when I tested your code and didn't copy & paste it properly. Consider my first message void. Upon further inspection, I actually don't see any problems with your code. I've tested it a number of times now and it works as expected.
In your first message you said it does absolutely nothing, but didn't elaborate on this. When you click the submit button, does your browser get redirected to js/process.php? This would be expected behaviour. If it does redirect, does your code display your warning message, or simply do nothing at all? If it does nothing, this would suggest the function executes correctly.
Consider writing a test script like this:
PHP Code:
mail('jgarrido@opticomsa.com.ar', 'Test subject', 'Message') or die('Error');
If the mail function still does not work, it could be a problem with your web hosting. At this point you would need to contact the host and ask them if SMTP is supported, since they may not have it installed, though this is unlikely.
Regarding your questions about testing code, I just save the files and upload them to a folder on my web server where I run them. No special folder structure is necessary. Most files reside in public_html or www.
It may be a long shot, but I've had issues with submit buttons in the past where I've given the name, type, id and other attributes the same name (all "submit") and the functionality of the button was disabled. Incidentally, the submit button doesn't need a name attribute.
It should make no difference what the file extension is. In cases where the problem is not forthcoming, I like to isolate the code in question and test it externally. Try copying just the code you need to test into a new file, along with your PHP handler in another, and see if it still does nothing.
If it works, you can assume something else in your source file(s) is affecting the functionality of the button. If it still does not work, I don't know what that could be.
Bookmarks