Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Contact Form problem I've had for a while.
Old 04-12-2005, 06:21 PM Contact Form problem I've had for a while.
Novice Talker

Posts: 11
Trades: 0
So I'm trying to figure out how to code "sendmail.php", which is where I want the submit button to go. Here is the current code I have for the form.

Code:
<FORM METHOD="POST" ACTION="sendmail.php">
Name:<br><INPUT TYPE="text" NAME="Name" SIZE="30"><br>
Email Address:<br><INPUT TYPE="text" NAME="Email Address" SIZE="30"><br>
Do you have shoutcast?<br>
Yes<INPUT TYPE="radio" NAME="Shoutcast" VALUE="Yes">
No<INPUT TYPE="radio" NAME="Shoutcast" VALUE="No">
<br>Have you ever used Shoutcast to DJ online?<br>
Yes<INPUT TYPE="radio" NAME="UsedSC" VALUE="Yes">
No<INPUT TYPE="radio" NAME="UsedSC" VALUE="no">
<br>Do you have a microphone?<br>
Yes<INPUT TYPE="radio" NAME="mic" VALUE="Yes">
No<INPUT TYPE="radio" NAME="mic" VALUE="No">
<br>Why should I choose you to DJ?<br><TEXTAREA NAME="Reason" ROWS=6 COLS=40></TEXTAREA>
<br>How many songs do you have?<br>
<INPUT TYPE="text" NAME="Songs" SIZE="30"><br>
I am available:<br>
Monday<INPUT TYPE="checkbox" NAME="Day" VALUE="Monday">
Tuesday<INPUT TYPE="checkbox" NAME="Day" VALUE="Tuesday">
Wednesday<INPUT TYPE="checkbox" NAME="Day" VALUE="Wednesday">
Thursday<INPUT TYPE="checkbox" NAME="Day" VALUE="Thursday">
Friday<INPUT TYPE="checkbox" NAME="Day" VALUE="Friday">
Saturday<INPUT TYPE="checkbox" NAME="Day" VALUE="Saturday">
Sunday<INPUT TYPE="checkbox" NAME="Day" VALUE="Sunday">
<br><INPUT TYPE="submit"></form>
I've been trying to figure out how to code it...I think I got it for the text boxes, but how do I code it for the radio buttons/check boxes?

Here's the code I have so far for that:
Code:
<?php
if (isset($_POST['submit'])){
if ($_POST['Name'] == ''){
echo "Please enter a name!";
}else{
if ($_POST['Email Address'] == ''){
echo "Please enter an email!";
}else{
mail("crazydog115@yahoo.com", "Subject", "$email", "My name is, $name\nEmail: $email\n Message: $message");
echo("Thank you for your submission.");
What do I need to add on to that for the radio buttons/checkboxes?
Crazydog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-12-2005, 07:28 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
At the moment you are not putting anything in the message variable? It's not anything special, it's just the contents of your message, so you can put checkbox and radio button stuff in there.

Your radio buttons are fine, but your checkboxes either need to have independent names (a value is not necessary since the 'value' can only be on or off) or they need to be submitted as an array. For a small number of CBs, it's simpler just to name them Monday, Tuesday.... etc
The post variable is then either set or unset depending on whether it was checked or not.
Along the lines of :
PHP Code:
if (isset($_POST['submit'])){
  if (
$_POST['Name'] == ''){
    echo 
"Please enter a name!";
  } else {
  if (
$_POST['Email Address'] == '') {
    echo 
"Please enter an email!";
  } else {
    
$message .="Has Shoutcast: ".$_POST['Shoutcast']."\n";
    
$message .="Has Used SC to DJ: ".$_POST['UsedSC']."\n";
    
//etc...
    
$message .= "Is available on the following days:\n";
    if(isset(
$_POST['Monday'])) $message.="Monday, ";
    if(isset(
$_POST['Tuesday'])) $message.="Tuesday, ";
    
//etc...
    
mail("crazydog115@yahoo.com""Subject""$email""My name is, $name\nEmail: $email\n Message: $message");
    echo(
"Thank you for your submission."); 
  }

__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-12-2005, 08:19 PM
Novice Talker

Posts: 11
Trades: 0
So for the checkboxes, I should change the "name" to the days of the week, and the value should be nonexistant?

edit: so I put at the top of the form...
Code:
<FORM METHOD="POST" ACTION="sendmail.php">
but when I go hit submit, it just goes to the page but just shows code...

Last edited by Crazydog; 04-12-2005 at 08:34 PM..
Crazydog is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 08:38 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
Crazydog,

What Oberon is saying is that you are having many boxes with the same values.

If you had the following it would work:

Code:
Monday<INPUT TYPE="checkbox" NAME="Monday">
Tuesday<INPUT TYPE="checkbox" NAME="Tuesday">
Wednesday<INPUT TYPE="checkbox" NAME="Wednesday">
Thursday<INPUT TYPE="checkbox" NAME="Thursday">
Friday<INPUT TYPE="checkbox" NAME="Friday">
Saturday<INPUT TYPE="checkbox" NAME="Saturday">
Sunday<INPUT TYPE="checkbox" NAME="Sunday">
The user would then tick one of the boxes and that value would be sent to the processor as a true value, whilst the rest would be false.

Steve.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by Gaffer Sports; 04-12-2005 at 08:43 PM..
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 04-12-2005, 10:33 PM
Novice Talker

Posts: 11
Trades: 0
Quote:
Originally Posted by Crazydog

Code:
<FORM METHOD="POST" ACTION="sendmail.php">
but when I go hit submit, it just goes to the page but just shows code...
I'm still having that problem though.
Crazydog is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 06:38 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
If it just shows you the PHP code then you've got a different problem, such as a missing ?> somewhere?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to Contact Form problem I've had for a while.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40880 seconds with 12 queries