Page 1 of 1

Finding information from radio buttons

Posted: Tue Jul 27, 2010 1:50 pm
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

Re: Finding information from radio buttons

Posted: Tue Jul 27, 2010 4:26 pm
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'];
}

Re: Finding information from radio buttons

Posted: Wed Jul 28, 2010 4:13 am
by stow
Thanks for that. So simple :/