IE problem with submitting forms

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
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

IE problem with submitting forms

Post by jefffan24 »

Hi I have yet another question about PHP (I've learned a lot though thanks to this website).

Ok so I have a mini webpage generator just so people can get an idea of what i offer (really simple), but I'm using forms with radio buttons. I have anywhere from 2-7 options on each page and there is 5 pages. On 4 of the 5 pages (all with 3 or more options to choose from) I have to submit the form twice. I click the choice I want hit next (which is a submit button), and it refreshes the page, I click my choice again and then it submits.

I have the users choices writing to a cookie and I don't know if that is causing the problem or if its just a generalized IE issue. Here's my code from 2 pages any ideas?? If you need more detail let me know and I'll try to explain further.

My Button page (for button types)

Code: Select all

 
<?php
 
$button = $_POST['button'];
 
if(!isset($_POST['submit'])){
 if($_COOKIE){
     echo "<div style='position:absolute; top:200px; left:20px;'><b>Your Selections so far:</b><br />";
     if($_COOKIE['Menu']){ echo "Menu Style: <b>" . $_COOKIE['Menu'] . "</b><br />"; }
     if($_COOKIE['button']){ echo "Button Style: <b>" . $_COOKIE['button'] . "</b><br />"; }
     if($_COOKIE['pgnums']){ echo "Page Number Style: <b>" . $_COOKIE['pgnums'] . "</b><br />"; }
     if($_COOKIE['bgcolor']){ echo "Background Color: <b>" . substr($_COOKIE['bgcolor'], 7) . "</b><br />"; }
     if($_COOKIE['fontcolor']){ echo "Font Color: <b>" . substr($_COOKIE['fontcolor'], 7) . "</b><br />"; }
     echo "</div>";
 }
 
    echo "<br /><br /><br /><br /><center> 
<h3>Click the buttons and hover over them to see what they do!</h3>
<form name=\"buttons\" id=\"buttons\" method=\"post\">
<br /><br /><input type=\"radio\" name=\"button\" id=\"number1\" value=\"2d No Hover\" /><input type=\"button\" style=\"width:175px;font-family:Verdana,Tahoma,Arial,Sans-Serif; font-size:14px; color:#000000; background-color:#c2c2c2; border:1px #000000 solid;\" class=\"buttonno\" value=\"2D no hover effect\" onclick=\"setCheckedValue(document.forms['buttons'].elements['button'], '2d No Hover');\" /><br /><br />
<input type=\"radio\" name=\"button\" value=\"2d With Hover\" /><input type=\"button\" style=\"width:175px;\" name-\"but\" class=\"buttonyes\" value=\"2D with hover effect\"  onclick=\"setCheckedValue(document.forms['buttons'].elements['button'], '2d With Hover');\" onmouseover=\"this.style.background='#FFFFCC'\" onmouseout=\"this.style.background='#c2c2c2'\" /><br /><br />
<input type=\"radio\" name=\"button\" value=\"3d Standard\" /><input type=\"button\" style=\"width:180px;\" value=\"3D standard hover effect\"  onclick=\"setCheckedValue(document.forms['buttons'].elements['button'], '3d Standard');\" /><br /><br />
</center><p align=\"right\" style=\"padding-right:300px;\">
<input type=\"submit\" name=\"submit\" value=\"Next\" /></p>
</form>"; 
 
//
 
 
} elseif (!$_COOKIE['Menu']){
    header ("location: menus.php");
    setcookie("button", $button);
} elseif (!$_COOKIE['pgnums']){
    header ("location: pagenumbers.php");
    setcookie("button", $button);
} elseif (!$_COOKIE['bgcolor']){
    header ("location: bgcolor.php");
    setcookie("button", $button);
} elseif (!$_COOKIE['fontcolor']){
    header ("location: fontcolor.php");
    setcookie("button", $button);
} elseif ($_COOKIE['Menu'] && $_COOKIE['pgnums'] && $_COOKIE['bgcolor'] && $_COOKIE['fontcolor']) {
    setcookie("button", $button);
    header ("location: cookie.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Select Your Button Style</title>
<link rel="stylesheet" type="text/css" href="buttoncss.css" />
<script type="text/javascript">
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}
 
// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
    if(!radioObj)
        return;
    var radioLength = radioObj.length;
    if(radioLength == undefined) {
        radioObj.checked = (radioObj.value == newValue.toString());
        return;
    }
    for(var i = 0; i < radioLength; i++) {
        radioObj[i].checked = false;
        if(radioObj[i].value == newValue.toString()) {
            radioObj[i].checked = true;
        }
    }
}
 
</script>
My Background Color page

Code: Select all

 
<?php
if(!$_COOKIE['bgcolor']){
    echo "You need to fill out the background page in order for this page to work correctly please <a href='bgcolor.php'>click here</a> to fill it out";
     if($_COOKIE){
     echo "<div style='position:absolute; top:200px; left:20px;'><b>Your Selections so far:</b><br />";
     if($_COOKIE['Menu']){ echo "Menu Style: <b>" . $_COOKIE['Menu'] . "</b><br />"; }
     if($_COOKIE['button']){ echo "Button Style: <b>" . $_COOKIE['button'] . "</b><br />"; }
     if($_COOKIE['pgnums']){ echo "Page Number Style: <b>" . $_COOKIE['pgnums'] . "</b><br />"; }
     if($_COOKIE['bgcolor']){ echo "Background Color: <b>" . substr($_COOKIE['bgcolor'], 7) . "</b><br />"; }
     if($_COOKIE['fontcolor']){ echo "Font Color: <b>" . substr($_COOKIE['fontcolor'], 7) . "</b><br />"; }
     echo "</div>";
 }
}
$fontcolor = $_POST['fontcolor'];
 
 
if(!isset($_POST['submit'])){
 if($_COOKIE){
     echo "<div style='position:absolute; top:200px; left:20px;'><b>Your Selections so far:</b><br />";
     if($_COOKIE['Menu']){ echo "Menu Style: <b>" . $_COOKIE['Menu'] . "</b><br />"; }
     if($_COOKIE['button']){ echo "Button Style: <b>" . $_COOKIE['button'] . "</b><br />"; }
     if($_COOKIE['pgnums']){ echo "Page Number Style: <b>" . $_COOKIE['pgnums'] . "</b><br />"; }
     if($_COOKIE['bgcolor']){ echo "Background Color: <b>" . substr($_COOKIE['bgcolor'], 7) . "</b><br />"; }
     if($_COOKIE['fontcolor']){ echo "Font Color: <b>" . $_COOKIE['fontcolor'] . "</b><br />"; }
     echo "</div>";
 }
    echo '<div style="position:absolute; top:250px; left:450px;">
    <h3>Choose your font color based on your background selection!</h3>
    <form name="fcolor" method="post">
    <label><input type="radio" name="fontcolor" value="#FFFFFF White" /><font color="white">White Text</font></label><br />
    <label><input type="radio" name="fontcolor" value="#008034 Green" /><font color="green">Green Text</font></label><br />
    <label><input type="radio" name="fontcolor" value="#FF0000 Red" /><font color="red">Red Text</font></label><br />
    <label><input type="radio" name="fontcolor" value="#2700FF Blue" /><font color="blue">Blue Text</font></label><br />
    <label><input type="radio" name="fontcolor" value="#FFFFCC Cream" /><font color="#FFFFCC">Cream Text</font></label><br />
    <label><input type="radio" name="fontcolor" value="#2F2F2F Grey" /><font color="#2F2F2F">Grey Text</font></label><br /><br />
    <input type="submit" name="submit" value="Next" />
    </form></div>';
} elseif (!$_COOKIE['Menu']){
    header ("location: menus.php");
    setcookie("fontcolor", $fontcolor);
} elseif (!$_COOKIE['button']){
    header ("location: button.php");
    setcookie("fontcolor", $fontcolor);
} elseif (!$_COOKIE['pgnums']){
    header ("location: pagenumbers.php");
    setcookie("fontcolor", $fontcolor);
} elseif (!$_COOKIE['bgcolor']){
    header ("location: bgcolor.php");
    setcookie ("fontcolor", $fontcolor);
} elseif ($_COOKIE['Menu'] && $_COOKIE['pgnums'] && $_COOKIE['button'] && $_COOKIE['bgcolor']) {
    setcookie("fontcolor", $fontcolor);
    header ("location: cookie.php");
    
}
 
?>
 
Thanks in advance.
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

Re: IE problem with submitting forms

Post by jefffan24 »

Nobody has anything? If you don't understand please let me know and I'll attempt to explain it better.
PortmoreEmpire
Forum Newbie
Posts: 1
Joined: Tue Nov 24, 2009 7:16 pm

Re: IE problem with submitting forms

Post by PortmoreEmpire »

Thanks for sharing here :)
Post Reply