Може ли някой да ми помогне с код за радио бутони и чекбокс. Искам да се избира само един радио бутон и да се праща в локалхост, а чекбокса да има възможност повече от един и пак да се запазва в локалхост. Да записва и изкарва след това, само въведените радио и чек бутони, това ми е кода :
Addguestbook.php :
<title>proekt - adminguestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
mysql_connect("localhost","user","pass")
or die ("Could not connect to datebase");
mysql_select_db("DB")
or die ("Could not select datebase");
mysql_query("SET CHARACTER SET utf8");
$name=$_POST['name'];
$phone=$_POST['phone'];
$car=$_POST['car'];
$family=$_POST['family'];
$yes=$_POST['yes'];
$no=$_POST['no'];
$sql="INSERT INTO tesk(`name`, `phone`, `car`, `family`, `yes`, `no`)
VALUES('$name', '$phone', '$car', '$family', '$yes', '$no')";
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'><strong>View Guestbook</strong></a>";
}
else {
echo "ERROR";
}
?>
Guestbook.php :
<html>
<head>
<title>proekt - guestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<tr>
<form method="post" action="addguestbook.php">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#AFFFFF">
<tr>
<td><b>Name : </b></td>
<td width="327">
<input name="name" type="text" size="40" maxlength="35"/>
</td>
<tr>
<td><b>Phone : </b></td>
<td width="327">
<input name="phone" type="text" size="40" maxlength="35"/>
</td>
<tr>
<td><b>Do you have a car : </b></td>
<td width="327">
<input name="car" type="checkbox" value="I have a car"/>
</td>
<tr>
<td><b>Do you have a family : </b></td>
<td width="327">
<input name="family" type="checkbox" value="I have a family"/>
</td>
<tr>
<td><b>Do you have a work, Yes : </b></td>
<td width="327">
<input name="yes" type="radio" value="yes"/>
</td>
<tr>
<td><b>Do you have a work, No : </b></td>
<td width="327">
<input name="no" type="radio" value="no"/>
</td>
<td>
<input type="submit" name="submit" value="Sign !" />
</td>
</table>
</td>
</form>
<tr>
<td>
<strong>
<a href="viewguestbook.php">View Guestbook</a>
</strong>
</td>
</tr>
</body>
</html>
Viewguestbook.php :
<title>proekt - viewguestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td>
<strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a></strong></td>
</tr>
</table>
<br>
<?php
mysql_connect("localhost","user","pass")
or die ("Could not connect to datebase");
mysql_select_db("DB")
or die ("Could not select datebase");
mysql_query("SET CHARACTER SET utf8");
$sql="SELECT * FROM tesk";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result))
{
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="117">Name </td>
<td width="14">:</td>
<td width="357"><? echo $rows["name"]; ?></td>
</tr>
<tr>
<td width="117">Phone </td>
<td width="14">:</td>
<td width="357"><? echo $rows["phone"]; ?></td>
</tr>
<tr>
<td width="117">Car </td>
<td width="14">:</td>
<td width="357"><? echo $rows["car"]; ?></td>
</tr>
<tr>
<td width="117">Family </td>
<td width="14">:</td>
<td width="357"><? echo $rows["family"]; ?></td>
</tr>
<tr>
<td width="117">Work </td>
<td width="14">:</td>
<td width="357"><? echo $rows["yes"]; ?></td>
</tr>
<tr>
<td width="117">Work </td>
<td width="14">:</td>
<td width="357"><? echo $rows["no"]; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
?>
Addguestbook.php :
<title>proekt - adminguestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
mysql_connect("localhost","user","pass")
or die ("Could not connect to datebase");
mysql_select_db("DB")
or die ("Could not select datebase");
mysql_query("SET CHARACTER SET utf8");
$name=$_POST['name'];
$phone=$_POST['phone'];
$car=$_POST['car'];
$family=$_POST['family'];
$yes=$_POST['yes'];
$no=$_POST['no'];
$sql="INSERT INTO tesk(`name`, `phone`, `car`, `family`, `yes`, `no`)
VALUES('$name', '$phone', '$car', '$family', '$yes', '$no')";
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'><strong>View Guestbook</strong></a>";
}
else {
echo "ERROR";
}
?>
Guestbook.php :
<html>
<head>
<title>proekt - guestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<tr>
<form method="post" action="addguestbook.php">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#AFFFFF">
<tr>
<td><b>Name : </b></td>
<td width="327">
<input name="name" type="text" size="40" maxlength="35"/>
</td>
<tr>
<td><b>Phone : </b></td>
<td width="327">
<input name="phone" type="text" size="40" maxlength="35"/>
</td>
<tr>
<td><b>Do you have a car : </b></td>
<td width="327">
<input name="car" type="checkbox" value="I have a car"/>
</td>
<tr>
<td><b>Do you have a family : </b></td>
<td width="327">
<input name="family" type="checkbox" value="I have a family"/>
</td>
<tr>
<td><b>Do you have a work, Yes : </b></td>
<td width="327">
<input name="yes" type="radio" value="yes"/>
</td>
<tr>
<td><b>Do you have a work, No : </b></td>
<td width="327">
<input name="no" type="radio" value="no"/>
</td>
<td>
<input type="submit" name="submit" value="Sign !" />
</td>
</table>
</td>
</form>
<tr>
<td>
<strong>
<a href="viewguestbook.php">View Guestbook</a>
</strong>
</td>
</tr>
</body>
</html>
Viewguestbook.php :
<title>proekt - viewguestbook.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td>
<strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a></strong></td>
</tr>
</table>
<br>
<?php
mysql_connect("localhost","user","pass")
or die ("Could not connect to datebase");
mysql_select_db("DB")
or die ("Could not select datebase");
mysql_query("SET CHARACTER SET utf8");
$sql="SELECT * FROM tesk";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result))
{
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="117">Name </td>
<td width="14">:</td>
<td width="357"><? echo $rows["name"]; ?></td>
</tr>
<tr>
<td width="117">Phone </td>
<td width="14">:</td>
<td width="357"><? echo $rows["phone"]; ?></td>
</tr>
<tr>
<td width="117">Car </td>
<td width="14">:</td>
<td width="357"><? echo $rows["car"]; ?></td>
</tr>
<tr>
<td width="117">Family </td>
<td width="14">:</td>
<td width="357"><? echo $rows["family"]; ?></td>
</tr>
<tr>
<td width="117">Work </td>
<td width="14">:</td>
<td width="357"><? echo $rows["yes"]; ?></td>
</tr>
<tr>
<td width="117">Work </td>
<td width="14">:</td>
<td width="357"><? echo $rows["no"]; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
?>