This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-17 19:55:12

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

PHP Send Form Results?

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.


http://i46.tinypic.com/dw7zft.png

Offline

 

#2 2012-04-17 21:43:46

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP Send Form Results?

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  smile


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#3 2012-04-17 21:53:40

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: PHP Send Form Results?

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.

Last edited by jvvg (2012-04-17 21:54:11)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#4 2012-04-17 21:58:02

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP Send Form Results?

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  hmm


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#5 2012-04-17 22:14:23

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: PHP Send Form Results?

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  hmm

I also think pretty much all UNIX/Linux systems are configured to be able to send mail, and my server runs Darwin UNIX.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#6 2012-04-18 00:17:15

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP Send Form Results?

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  hmm

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  tongue


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#7 2012-04-18 07:04:08

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: PHP Send Form Results?

jji7skyline wrote:

jvvg wrote:

jji7skyline wrote:


Really? A programmer friend of mine said you have to  hmm

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  tongue

Perhaps I should be more specific: I have Mac OS X running on the Darwin UNIX kernel.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#8 2012-04-18 07:09:50

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: PHP Send Form Results?

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:

Code:

<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)


http://i46.tinypic.com/dw7zft.png

Offline

 

#9 2012-04-18 21:18:22

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: PHP Send Form Results?

Anyone?


http://i46.tinypic.com/dw7zft.png

Offline

 

#10 2012-04-18 23:39:50

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: PHP Send Form Results?

JavaScript "onClick: 'var x = 1', etc maybe.

IDK tbh


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#11 2012-04-19 07:04:00

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Re: PHP Send Form Results?

bbbeb wrote:

JavaScript "onClick: 'var x = 1', etc maybe.

IDK tbh

?


http://i46.tinypic.com/dw7zft.png

Offline

 

#12 2012-04-19 08:15:13

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: PHP Send Form Results?

Set the value of a hidden input with the form results, maybe?


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

Board footer