Finding information from radio buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stow
Forum Newbie
Posts: 13
Joined: Tue Jul 27, 2010 1:31 pm

Finding information from radio buttons

Post by stow »

Hi all,

Ok, here's the problem I've been having. Based on the customers in the table a list is made so that radio buttons are set out for each customer. I did this using the following php:

Code: Select all

<?php
$connection = mysql_connect("server","user","pass");
$db=mysql_select_db("db", $connection);

$cust = "SELECT customer FROM list";
$sql = mysql_query($cust) or die(mysql_error());
while ($row = mysql_fetch_array($sql))
{
	echo "<input type=\"radio\" name=\"customer\" value='".$row['cust']"'>".$row['cust']."</input>";
}
?>
That works out fine. The problem comes when I try process the radio button ticked. So if customer John bought a Chair the chair file item would be listed on johns page. the chair file item has its details on it if john wants to download and view it. I wanted to move to the ticked customers directory. I've tried the following code but I really have no idea what to put in the commented part.

Code: Select all

<?php
$connection = mysql_connect("localhost","root","Mineallmine");
$db=mysql_select_db("test", $connection);

if(isset($_POST['customer'])
{
	//What goes here?
}
	
if(!file_exists("upload"))
{
	mkdir("/upload", 0777);
}
if($_FILES["file"]["error"] > 0)
{
	echo $_FILES["file"]["error"];
}
else
{
	echo "Uploaded File: ".$_FILES["file"]["name"]."<br />";
	echo "Size of File: ".($_FILES["file"]["size"] / 1024)."Kb<br />";
	if(file_exists("upload/".$_FILES["file"]["name"]))
	{
		echo $_FILES["file"]["name"]." all ready exists in the upload directory";
	}
	else
	{

		move_uploaded_file($_FILES["file"]["tmp_name"], $customer."/upload/".$_FILES["file"]["name"]);
		echo "File has been stored successfully";
	}	
}

?>
Any help would be appreciated.

Thanks

Stow
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Finding information from radio buttons

Post by internet-solution »

stow wrote:

Code: Select all

<?php
if(isset($_POST['customer'])
{
	//What goes here?
}
Try:

Code: Select all

<?php
if(isset($_POST['customer'])
{
	$customer=$_POST['customer'];
}
stow
Forum Newbie
Posts: 13
Joined: Tue Jul 27, 2010 1:31 pm

Re: Finding information from radio buttons

Post by stow »

Thanks for that. So simple :/
Post Reply