Jump to content

[SOLVED] Problem with write to file and radio buttons..


runeberg1

Recommended Posts

Hello!

 

I'm new to the php language.

I'm working on a school project where we are building a small CMS.

 

This is the "Choos Design" area.

It works with writing to file "design.db" from admin area and the public web page reads css from content in "design.db"

 

Currently it is working with two different designs in css, black and white.

 

Now I need the part, something like:

If content in $DesignFile = "black.css" then $black_status = 'checked' in form.

 

Status now: If nothing is checked then the file "design.db" gets "empty" and therefore no css on main public area.

 

 

<?
$DesignFile = "include/design.db"; 
$Handle = fopen($DesignFile, 'w');

$BlackData = "black.css"; 
$WhiteData = "white.css";

if (isset($_POST['Set_design'])) {

$black_status = 'unchecked';
$white_status = 'unchecked';

$selected_radio = $_POST['design'];

	if ($selected_radio == 'black') {
		$black_status = 'checked';
		fwrite($Handle, $BlackData); 

	}
	else if ($selected_radio == 'white') {
		$black_status = 'checked';
		fwrite($Handle, $WhiteData); 
	}
}
fclose($Handle);
?> 
<FORM NAME ="form1" METHOD ="POST" ACTION ="choose_design.php">

<INPUT TYPE = 'Radio' Name ='design'  value= 'sort' <?PHP print $black_status; ?>>Sort

<INPUT TYPE = 'Radio' Name ='design'  value= 'hvid' <?PHP print $white_status; ?>>Hvid
<P>
<INPUT TYPE = "Submit" Name = "Set_design"  VALUE = "Vælg design" style=" background-color: #000000; color: #FFFFFF;">
</FORM>

 

I really hope you can help me.

 

Thanks.

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.