I coded a HTML form with javascript creating a price estimator for my friend's company. I'm wondering how I can convert this using PHP into an email when a button is pressed? Here's a better explanation: Person selects options they want, then type in their name. They click the send button and then it sends the options they selected via HTML radiobuttons and checkboxes to my friend's email.
I'm a terrible explain-er.
Offline
Make the HTML form report the results into a PHP script.
Then use the PHP script and the mail function to email.
As far as I know, you also have to have a mail server to use the PHP mail fuction
Offline
So, you need the form:
<form action="somepage.php" method="post" enctype="multipart/form-data"> <input type=text name="something" /> Some options <select name="options"> <option>Option 1</option> <option>Option 2</option> </select> </form>
And then on somepage.php (or whatever you set the processor to, add:
<?php
$data = $_POST['something'];
mail('Somebody <somebody@gmail.com>', 'Subject', 'Typed in: ' . $data . ' and selected: ' . $_POST['options'], 'From: Somebodyelse <somebody@else.com');
?>In this case, you would need to do the price estimate in the PHP code (modify $data).
EDIT: I set up a PHP server at my house, and I didn't need to set up any mail server stuff.
Last edited by jvvg (2012-04-17 21:54:11)
Offline
jvvg wrote:
So, you need the form:
Code:
<form action="somepage.php" method="post" enctype="multipart/form-data"> <input type=text name="something" /> Some options <select name="options"> <option>Option 1</option> <option>Option 2</option> </select> </form>And then on somepage.php (or whatever you set the processor to, add:
Code:
<?php $data = $_POST['something']; mail('Somebody <somebody@gmail.com>', 'Subject', 'Typed in: ' . $data . ' and selected: ' . $_POST['options'], 'From: Somebodyelse <somebody@else.com'); ?>In this case, you would need to do the price estimate in the PHP code (modify $data).
EDIT: I set up a PHP server at my house, and I didn't need to set up any mail server stuff.
Really? A programmer friend of mine said you have to
Offline
jji7skyline wrote:
jvvg wrote:
So, you need the form:
Code:
<form action="somepage.php" method="post" enctype="multipart/form-data"> <input type=text name="something" /> Some options <select name="options"> <option>Option 1</option> <option>Option 2</option> </select> </form>And then on somepage.php (or whatever you set the processor to, add:
Code:
<?php $data = $_POST['something']; mail('Somebody <somebody@gmail.com>', 'Subject', 'Typed in: ' . $data . ' and selected: ' . $_POST['options'], 'From: Somebodyelse <somebody@else.com'); ?>In this case, you would need to do the price estimate in the PHP code (modify $data).
EDIT: I set up a PHP server at my house, and I didn't need to set up any mail server stuff.Really? A programmer friend of mine said you have to
![]()
I also think pretty much all UNIX/Linux systems are configured to be able to send mail, and my server runs Darwin UNIX.
Offline
jvvg wrote:
jji7skyline wrote:
jvvg wrote:
So, you need the form:
Code:
<form action="somepage.php" method="post" enctype="multipart/form-data"> <input type=text name="something" /> Some options <select name="options"> <option>Option 1</option> <option>Option 2</option> </select> </form>And then on somepage.php (or whatever you set the processor to, add:
Code:
<?php $data = $_POST['something']; mail('Somebody <somebody@gmail.com>', 'Subject', 'Typed in: ' . $data . ' and selected: ' . $_POST['options'], 'From: Somebodyelse <somebody@else.com'); ?>In this case, you would need to do the price estimate in the PHP code (modify $data).
EDIT: I set up a PHP server at my house, and I didn't need to set up any mail server stuff.Really? A programmer friend of mine said you have to
![]()
I also think pretty much all UNIX/Linux systems are configured to be able to send mail, and my server runs Darwin UNIX.
Well, I have a Mac so yea
Offline
jji7skyline wrote:
jvvg wrote:
jji7skyline wrote:
Really? A programmer friend of mine said you have to![]()
I also think pretty much all UNIX/Linux systems are configured to be able to send mail, and my server runs Darwin UNIX.
Well, I have a Mac so yea
![]()
Perhaps I should be more specific: I have Mac OS X running on the Darwin UNIX kernel.
Offline
Anyway, here's more of what I want. The price calculation is totally separate and does not go into the email. Here's an example of part of the form:
<form name=parts onclick=getTotal() > <h1>Hard Drive Space</h1></div> <input type="radio" name="hdrive" checked value="25" /> 100 GB - Great for storing photos and documents. - $25<br /> <input type="radio" name="hdrive" value="50" /> 500 GB - Enough space to store games and videos as well as lots of programs. - $50<br /> <input type="radio" name="hdrive" value="100" /> 1 TB (1000 GB) - Tons of space to store hours of video or high quality games. - $100<br /> <input type="checkbox" name="hdrive" value="150" /> 750 GB SSD (Solid State Drive) - A super fast SSD so you can access the files you need quickly. - $150<br />
A JS script adds the values of the selected items together and shows it. I know how to send email via PHP but I am wondering how to convert the checkboxes and radiobuttons that are selected into a list which will be the email message.
Last edited by SeptimusHeap (2012-04-18 07:10:09)
Offline