Hi all, i just registered since i cant resolve this myself and im on a really tight schedule.
anyway im building this website and i’ve got the form as follows
<form id="form1" action="contact.php" method="post">
<div class="success"> Contact form submitted!<br><strong>We will be in touch soon.</strong> </div>
<fieldset>
<label class="name">
<input type="text" value="Name:">
<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label>
<label class="email">
<input type="email" value="E-mail:">
<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span> </label>
<label class="phone">
<input type="tel" value="Phone:">
<span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span> </label>
<label class="message">
<textarea>Message:</textarea>
<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>
<div class="btns und"><a href="#" class="btn" data-type="reset">clear</a><a href="#" class="btn" data-type="submit">submit</a></div>
</fieldset>
</form>
and i found this code snippet online but i cant get it to work…
That’s a pretty crummy script you have there. It has no defense against spammers. But one reason it’s not working for you is that the HTML inputs are lacking the name=“” attribute, which sends information to the PHP script. For example, the first label/input should be something like this:
I actually fixed it, it was missing onclick(Submit()) now it sends the email and all… but can i stop it from opening a blank page ? can i instead make it pop an alert window “Mail sent” OK in the existing window
it seems to work now opposed to before using it … anyway heres the code if it helps:
<form id="form1" action="contact.php" method="POST">
<div class="success"> Contact form submitted!<br><strong>We will be in touch soon.</strong> </div>
<fieldset>
<label class="name">
<input type="text" name="name" value="Name:">
<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label>
<label class="email">
<input type="email" name="email" value="E-mail:">
<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span> </label>
<label class="phone">
<input type="tel" name="phone" value="Phone:">
<span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span> </label>
<label class="message" name="message" >
<textarea name="message">Message:</textarea>
<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>
<input type="button" value="Submit Form" onclick="submit();">
</fieldset>
</form>
And the PHP file which i edited for now just to show me if it sent the mail :
FYI you should not even bother getting a script working with no protection. 2 months from now you will only be looking for better once you or your client start getting 100 spams a week. If its worth doing, it’s worth doing right.