Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Background Color Changer in a new page

Links for php scripts

Moderators: macek, egami, gesf

Background Color Changer in a new page

Postby Stephen » Fri Jul 06, 2012 12:28 pm

Hi All,

Im am very new to PHP, Im trying to write a background colour changer that when the form is submitted a new page displays the colour they selected.
Here is the code I have so far. I think the code on this page is ok. The problem I have is I really dont know how to get it working on the second page. .


Code: Select all
<html>
<head>
<?php
// creates a session that is kept between the pages
session_start();
$white_status='unchecked';
$pink_status='unchecked';
$blue_status='unchecked';
$green_status='unchecked';

if(isset($_POST['SUBMIT1']))

{
$selected_radio = $_POST['color'];

if($selected_radio =='white')
{
$white_status = 'checked';
$color = 'fffff';
}

else if
($selected_radio =='pink')
{
$pink_status = 'checked';
$color = 'FF00FF';
}

else if
($selected_radio =='green')
{
$green_status ='checked';
$color='008000';
}
}
?>
</head>


<body>
<FORM NAME ="form1" METHOD="POST" ACTION="page2.php">
<input type="radio" name="color" value="colour" onClick=document.bgColor=fffff">White
<input type="radio" name="color" value="colour" onClick=document.bgColor=FF00FF">pink
<input type="radio" name="color" value="colour" onClick=document.bgColor=008000">green
</br></br>
<INPUT TYPE ="Submit" Name = "Submit1" VALUE=CHANGECOLOUR>
</FORM>
</html>


any help greatly appreciated
Stephen
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Jul 06, 2012 12:11 pm

Re: Background Color Changer in a new page

Postby johnj » Fri Jul 06, 2012 10:18 pm

When you go to the second page, pick the color that was posted and show that as the background color for the new page.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.