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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.