Jump to content

[SOLVED] check box


janim

Recommended Posts

ok i explain it

 

add a field in your db for the hide or not

<input name="Check_hphone" type="checkbox" value="Check_hphone" />

value for that should only Y or N to save space

 

heres how to view

 

while($x=mysql_fetch_assoc($query)):

  if ($x[hideORnot]==y)

//show email

endwhile;

 

something like that

 

 

Link to comment
https://forums.phpfreaks.com/topic/63476-solved-check-box/#findComment-316358
Share on other sites

include("config.php");

$link=mysql_connect($server,$datauser,$datapass)
or die("connection faild becouse".mysql_error());
mysql_select_db($database)
or die("No database".mysql_error());
$check = "select id from $table where email = '".$_POST['email']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Sorry, this E-mail $email is registered before.";exit;}
$insert = mysql_query("insert into $table values ('NULL', '".$_POST['name']."', '".$_POST['email']."', '".$_POST['con']."', '".$_POST['hphone']."', '".$_POST['mphone']."','".$_POST['key']."','".$_POST['sex']."','".$_POST['town']."','".$_POST['position']."','".$_POST['min_salary']."','".$_POST['min_hourly']."','".$_POST['user']."','".$_POST['check_mail']."')")
or die("Could not insert data because ".mysql_error());

 

<input name="check_mail" type="checkbox" value="1"/>

Link to comment
https://forums.phpfreaks.com/topic/63476-solved-check-box/#findComment-316374
Share on other sites

have your coding this way

include("config.php");
$link=mysql_connect($server,$datauser,$datapass)or die("connection faild becouse".mysql_error());
mysql_select_db($database)or die("No database".mysql_error());
$check = "select id from $table where email = '".$_POST['email']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Sorry, this E-mail $email is registered before.";exit;}
	$insert = mysql_query("insert into $table values 
					('NULL', 
					'".$_POST['name']."', 
					'".$_POST['email']."', 
					'".$_POST['con']."', 
					'".$_POST['hphone']."', 
					'".$_POST['mphone']."',
					'".$_POST['key']."',
					'".$_POST['sex']."',
					'".$_POST['town']."',
					'".$_POST['position']."',
					'".$_POST['min_salary']."',
					'".$_POST['min_hourly']."',
					'".$_POST['user']."',
					'".$_POST['check_mail']."')") or die("Could not insert data because ".mysql_error());
}
if you can insert others why not in this field its just the same to check echo the post for that check if it really has a value or echo your query to know if the DB or PHP code is the prob

Link to comment
https://forums.phpfreaks.com/topic/63476-solved-check-box/#findComment-316377
Share on other sites

example u need to add the database insert names values ok.


<?php
include("config.php");

$link=mysql_connect($server,$datauser,$datapass)or die("connection faild becouse".mysql_error());

mysql_select_db($database)or die("No database".mysql_error());

$check = "select id from $table where email = '".$_POST['email']."';";

$qry = mysql_query($check)

or die ("Could not match data because ".mysql_error());

$num_rows = mysql_num_rows($qry);

if ($num_rows != 0) {

echo "Sorry, this E-mail $email is registered before.";

exit;

}
$name=mysql_real_escape_string($_POST['name']); 
$email=mysql_real_escape_string($_POST['email']); 
$con=mysql_real_escape_string($_POST['con']); 
$hphone=mysql_real_escape_string($_POST['hphone']); 
$key=mysql_real_escape_string($_POST['key']); 
$sex=mysql_real_escape_string($_POST['sex']); 
$town=mysql_real_escape_string($_POST['town']); 
$postion=mysql_real_escape_string($_POST['postion']); 
$min_salary=mysql_real_escape_string($_POST['min_salary']); 
$min_hourly=mysql_real_escape_string($_POST['min_hourly']); 
$user=mysql_real_escape_string($_POST['user']); 
$check_mail=mysql_real_escape_string($_POST['check_mail']); 

$insert = mysql_query("insert into $table values 
					('NULL', 
					'$name', 
					'$email', 
					'$con', 
					'$hphone', 
					'$mphone',
					'$key',
					'$sex',
					'$town',
					'$position',
					'$min_salary',
					'$min_hourly',
					'$user',
					'$check_mail' ") or die("Could not insert data because ".mysql_error());
?>

Link to comment
https://forums.phpfreaks.com/topic/63476-solved-check-box/#findComment-316391
Share on other sites

aha thank you i got the idea

but how can i insert Y or NO into database when i tried '".$POST['check_mail']."' i foubd the field empty in mysql

so how can i insert it  ??? ??? ??? ??? :D :D ;D ;D

 

One thing to be aware of with checkboxes - only checked values are posted. If you want Y/N values to write to db then

$check_mail = isset($POST['check_mail']) ? 'Y' : 'N' ;

 

and write $check_mail to the db table.

Link to comment
https://forums.phpfreaks.com/topic/63476-solved-check-box/#findComment-316540
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.