Jump to content


Photo

yes no valadation on check box


  • Please log in to reply
5 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 May 2006 - 02:13 PM

advance thank you.

I am using a date array function, and i wont the user to be able to say if they have any dates not to use
via a yes and no check box.

The varables for dates is:


$date1
$date2
$date3
$date4


<input name="dates" type="checkbox" value="yes">Yes
<input name="dates" type="checkbox" value="no">no


how do i get a valadition to see if the user has said no then dont insert to database, And if yes insert to database.

example only

if ($dates =="no") {

$date1 $date2 $date3 $date4

}else{ 


if($dates =="yes") {

$date1 $date2 $date3 $date4

INSERT INTO DATABASE
}
}

So how do i join a no or yes to a corrersponding code.

or is this a existing proper code

if(($dates=="no")==($date1 && $date2 && $date3 && $date4)){
do nothink
}



if(($dates=="yes")==($date1 && $date2 && $date3 && $date4)){

INSERT INTO DATABASE

}





Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 03 May 2006 - 02:32 PM

Might be better of using a radio button rather than a check box

YES<input type=radio name=date1r value=yes>&nbsp;&nbsp;NO<input type=radio name=date1r value=no>
YES<input type=radio name=date2r value=yes>&nbsp;&nbsp;NO<input type=radio name=date2r value=no>
YES<input type=radio name=date3r value=yes>&nbsp;&nbsp;NO<input type=radio name=date3r value=no>
YES<input type=radio name=date4r value=yes>&nbsp;&nbsp;NO<input type=radio name=date4r value=no>

Ray

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 May 2006 - 02:36 PM

Ray how to valadate a yes or no for the $date to be inserted to database mate

example all as one so if they press yes the insert goes if they press no the insert dosent go.


your code correct and nice thank you but one yes and one no ok

<input type=radio name=dates value=yes>Yes
<input type=radio name=dates value=yes>NO

[code]


what is the correct syntex code to join all as one together to valadate


example does this join a yes or no together with $dates. 

if(($dates=="no")==($date1r && $date2r && $date3r && $date4r)){
do nothink
}



if(($dates=="yes")==($date1r && $date2r && $date3r && $date4r)){

INSERT INTO DATABASE

}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 03 May 2006 - 02:54 PM

What is the structure for the table where the dates will be inserted??

Ray

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 May 2006 - 03:27 PM

this on check.php

if you press yes echo yes if you press no echo no

is this correct not working



if(!$datecheck=="yes") {
echo "yes";
exit;
}


if(!$datecheck=="no") {
echo "no";
exit;
}


this on post.php
<input name="datecheck" type="checkbox" value="yes">Yes
<input name="datecheck" type="checkbox" value="no">no

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 03 May 2006 - 03:49 PM

[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]


If the user press yes the database gets the dates, But if the user press no the user gets defult dates.


if($datecheck=="yes") {

$days = array();
$month = array();
$years = array();
foreach($_POST as $key => $value){
if (substr($key, 0, 5) == 'month'){
$months[]=$value;
}
if (substr($key, 0, 3) == 'day'){
$days[].=$value;
}
if (substr($key, 0, 4) == 'year'){
$years[]=$value;
}
}
$dates1 = ''.$days[0].'-'.$months[0].'-'.$years[0].'';
$dates2 = ''.$days[1].'-'.$months[1].'-'.$years[1].'';
$dates3 = ''.$days[2].'-'.$months[2].'-'.$years[2].'';
$dates4 = ''.$days[3].'-'.$months[3].'-'.$years[3].'';

INSERT INTO DATABASE

}

if($datecheck=="no") {

$dates1 ="0-0-0000";
$dates2 ="0-0-0000";
$dates3 ="0-0-0000";
$dates4 ="0-0-0000";


INSERT INTO DATABASE
}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users