fuzzyjon79
asked on
Web form mailer
I have no idea what I'm doing when it comes to php. I am putting a contact form on my sister's webpage, but I have no idea how to make it take the information input by the user and send it to the email address she wanted me to use. My hosting is on godaddy.com and they created two php files on the root directory when her hosting account was created. It is being hosted on a Linux server. The two php files created are webformmailer.php and gdform.php. What additional code do I need to use to get the input to the email address? Thanks in advance.
<center><form method="post" action="webformmailer.php">
Name: <input name="name" type="text"><br />
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form></center>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I do this - I believe you need to log on to godaddy and set up who is the recipient:
<script type="text/javascript">
function validate(theForm) {
if (theForm.email.value=="") {
alert('Please enter an email address');
theForm.email.focus();
return false;
}
theForm.action="gdform.php"; // helps cut down on robots
return true;
}
</script>
<form action="#" method="post" onSubmit="return validate(this)">
<input type="hidden" name="subject" value="Mail from my site">
<input type="hidden" name="redirect" value="thankyou.html">
Name: <input name="name" type="text"><br />
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form>
ASKER
Okay, I've got the form working correctly now. The only problem I have is that when the user clicks the submit button, they get no confirmation message. What code would I add to keep them on the same page and just display a "Your message was sent successfully" confirmation message? Also, would I add it to the webformmailer.php file or the contacts page?
You can use AJAX or do it the old fashioned way
Keep the script I gave you but change the action to webfommailer.php and have
<form action="#" method="post" onSubmit="return validate(this)" target="thankyouFrame">
<input type="hidden" name="redirect" value="thankyou.html">
.
.
.
<iframe src="about:blank" name="thankyouFrame" width="200" height="20"></iframe>
and in your thankyou.html have
<h2>Your message was sent successfully</h2>
Keep the script I gave you but change the action to webfommailer.php and have
<form action="#" method="post" onSubmit="return validate(this)" target="thankyouFrame">
<input type="hidden" name="redirect" value="thankyou.html">
.
.
.
<iframe src="about:blank" name="thankyouFrame" width="200" height="20"></iframe>
and in your thankyou.html have
<h2>Your message was sent successfully</h2>
Hmm
ASKER