Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox form validation

Status
Not open for further replies.

rastaIT34

Technical User
Sep 9, 2009
103
US
this is a two part question.


1] i have a web form that has <input> text fields and one check box. I am using a php script to process the form. For some reason the script is not showing whether the check box is on or off.

My question is how can I edit the script or the html form so the php script processes that the user has selected the check box. Currently the email that i receive just shows blank regardless if checked or not.

PHP processor script:

Code:
<?php

//*****************************************************************************	
// This scripts is a product of MyKazaam.Com. Please see the enclosed files	*
// or website for license and restrictions. Support is available from our	*
// website at [URL unfurl="true"]http://www.mykazaam.com.[/URL] Installation is also available. 		*
// Both of these services are accompanied by a nominal fee. Please try 		*
// to use the forums located on the website before buying support. 		*
//*****************************************************************************


//-----------------------------------------------------------------------------


//*************************************
// Variables to customize this script.* 
//******vvvvvvvvvvvvvvvvvvvvvvvv*******

$email_address = "rscr@rossow-web.com";
// your e-mail address goes here
// this is the address where your form info will be sent
// use a complete address such as something@something.com

$email_subject = "Basketball Camp Registration Form from ryanmartinbasketball.org";
// the subject line for the e-mail goes here
// this line will appear as the subject of any form
// submissions that are sent. Use something that will
// help you identify what form it is from. 
// such as "Work Order Request". 

$from_email_name = "rscr@rossow-web.com";
// the from address goes here 
// this is just the from header that will be displayed in
// the email that is sent to you. You can use your own 
// e-mail address here also if you would like. 


$show_ip_address = "off";
// "on" to show ip address, "off" to leave the ip address out of the e-mail

$show_refering_page = "off";
// "on" to show the form that sent user to this script, otherwise "off"

$show_browser_type = "off";
// "on" to show what browser the user has, otherwise "off"

$show_date_and_time = "on";
// "on" to show the date and time sent, otherwise "off"


$redirect_to_page = "[URL unfurl="true"]http://ryanmartinbasketball.org/registration_FormSent.html";[/URL]
// enter the web address where the user should be sent after completing the form


//*********************************
// DO NOT EDIT BELOW THIS LINE!!!**
//*********************************


$mailTo = "$email_address";

$mailSubject = "$email_subject";

$mailBody = "Below is a completed Basketball Camp Registration Form form ryanmartinbasketball.org. \n\n";

foreach($HTTP_POST_VARS as $key=>$value)
{

$mailBody .= "$key = $value\n";

}


$mailBody .= "\n\n";

if ($show_ip_address == "on")
{

$mailBody .= "THE IP ADDRESS OF THE FORM USER IS: $REMOTE_ADDR\n\n";

}


if ($show_refering_page == "on")
{

$mailBody .= "THE USER WAS SENT TO THIS SCRIPT FROM THE FOLLOWING FORM: $HTTP_REFERER\n\n";

}


if ($show_browser_type == "on")
{

$mailBody .= "THE USER USED THE FOLLOWING BROWSER TYPE: $HTTP_USER_AGENT\n\n";

}


if ($show_date_and_time == "on")
{

$mailBody .= "THE TIME AND DATE THE FORM WAS COMPLETED: " . date("h:i A l F dS, Y") . "\n\n";

}


$mailBody .= "\n \n \n";


$fromHeader = "From: $from_email_name\n";


if(mail($mailTo, $mailSubject, $mailBody, $fromHeader)) 
{

print ("<B>Your form has been sent!<br></b>");

}

echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$redirect_to_page\">";

?>


and


2] As you can see in the <head> section i already have a validation for the text form fields. I already Googled for the answer with no success. Actually the check box is required so i want to pop up a JavaScript window stating the user must select it in order to submit the form.

Webpage:
any help would be appreciated!



Artist/Designer
 
Hi

1] Give a readable [tt]value[/tt] to the checkbox. The presence or absence of the empty string is hard to see. Beside that, note that the browsers submit only the checked checkboxes.

2] Off-topic, for further JavaScript questions visit forum216. In meantime :
JavaScript:
[b]if[/b] [teal](![/teal]document[teal].[/teal]forms[teal][[/teal][green][i]"myForm"[/i][/green][teal]].[/teal]elements[teal][[/teal][green][i]"Parental Consent"[/i][/green][teal]].[/teal]checked[teal])[/teal] [teal]{[/teal]
  [COLOR=darkgoldenrod]alert[/color][teal]([/teal][green][i]"Please express your consent by checking that box."[/i][/green][teal]);[/teal]
  [b]return[/b] [b]false[/b][teal];[/teal]
[teal]}[/teal]


Feherke.
 
Feherke,


Awesome to the javascript solution!!! I actually figured out the check box value thing by experimenting... but thanks anyway!



Artist/Designer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top