Form/PHP help...alot of it<

liunx

Guest
Ok, I dont' think anyone will actually walk me all the way through this, but Im going to ask anyway.

Alrighty, I'm doing the last thing for the work site. I'm making a contact page. I tried to use the webmonkey forms tutorial to make the form, and I think I have a form..but I don't think it's right.

Also, I dont' know which to use, get or post, and I dont' know how to write the php to actually email this to the correct email address.

Here's the html I have..


<form action="nextpage.html" method="get" name="contact_form">
Name: <input type="text" name="name" size="50"><br><br>
Address: <input type="text" name="address" size="50"><br>
City: <input type="text" name="city" size="20">
State: <input type="text" name="state" size="2" maxlegnth="2">
Zip Code: <input type="text" name="zip" size="5" maxlegth="5">
<br><br>
Phone Number: <input type="text" name="phone" size="12" maxlegnth="12"><br><br><br>
Potential Dollar amount of assets to transfer:<br><br>
<input type="radio" name="assets" value="250k" checked>$250,000 to $500,000<br>
<input type="radio" name="assets" value="500k">$500,000 to $1M<br>
<input type="radio" name="assets" value="over1m">$1M or more<br>
<br><br>
I would like to meet with an advisor <input type="Checkbox" name=contact [] value="appointmentt">
<br>
I would like information about the next workshop <input type="Checkbox" name=contact [] value="RAP"><br>
<br><br>

Is there any additional information you would like to provide?<br><br>
<textarea cols=50 rows=6 name="comments"></textarea>
</form>


I just left nextpage.html in the action because I don't know what else to put in there...I'm assuming, write it, the name of my php script.

If someone can walk me through how to do this or point me to a really really good tutorial, I'd be super greatful :D

pleeeeease :)The action should be the name of the php script that sends the email.

Here's an example:
<!-- m --><a class="postlink" href="http://alphibia.com/phpscripts.php?p=6">http://alphibia.com/phpscripts.php?p=6</a><!-- m -->

if you still have questions i'll be back in a couple hoursok, here's where I'm at now..and now, I have a much more specific question :D

I'm actually IMing will about this, and he's explaining, but he's going over my head still :(

I get most of this now, I think, but I have a couple of questions.

1) Sicne the variables are sent to the script by the form thingy, I don't need to declare them?

2) Do I need to do the loop thingy to get all the information from my checkboxes?

After this, I *think* I'll be good to go :DOne more questions. Here is what Will said (and he explains things well, but he's still...I don't get it).

Will: $_POST is the php superglobal for form variables that arrive using the "post" method...think of it as just another array....
Will: example..if I had a text field named "username" and I submitted to file.php and wanted to display the entered username I'd use:

<?
echo $_POST["username"];
?>

But, the tutorial I read, said that with the check boxes you send it in an array. So, how would that work?I'm not sure what you mean by declare them?
save I have an input box called name, the variable would be $_POST['name']. Now I could assign another variable to this, to make it easier to type. like
$name = $_POST['name'];
I've never dealt with check boxes, so I'm not really sure what to do. I'm guessing it's some kind of multidemsional array, maybe $_POST['checkbox']['checkboxname']
but that's just a guess.nevermind.

Thanks anyway Josh.Checkboxes:
set them up so that they have name="whatever[]"
The red part lets it know to send them as an array. If you have 2 sets of checkboxes, name them whatever1[] & whatever2[] but anything with the same name will be sent as 1 array.

more specific code:
I would like to meet with an advisor <input type="Checkbox" name="contact[]" value="appointmentt"><br>
I would like information about the next workshop <input type="Checkbox" name="contact[]" value="RAP"><br><br><br>
for($i=0;$i<sizeof($_POST['contact']);$i++){
switch($_POST['whatever'][$i]){
case 'appointmentt':
echo "would like to meet with an advisor";
break;
case 'RAP':
echo "would like information about the next workshop";
break;
}
}Since you don't have that many checkboxes, it should be easy...just ass a new CASE if you add a new checkbox.

EDIT: I left off a } so I fixed it.I got it working, and I understand it alot better. Thanks guys :)
 
Back
Top