Welcome to Dream.In.Code
Become an Expert!

Join 150,177 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,157 people online right now. Registration is fast and FREE... Join Now!




Php script works fine with Firefox but not in Internet Explorer

2 Pages V  1 2 >  
Reply to this topicStart new topic

Php script works fine with Firefox but not in Internet Explorer

msvp4u
27 Aug, 2008 - 08:03 PM
Post #1

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 60


My Contributions
My php script works fine in Firefox but when I tested with Internet Explorer i threw an error.

When I press the Submit button it shows done with a warning symbol and the error message displayed is :

Error: 'adduser.txtFname.value' is null or not an object

the code is as follows .

Best suited solution will be appreciated.

CODE

<?php
?>
<html>

<head>
</head>
<body bgcolor=floralwhite leftmargin="0" topmargin="0" marginwidth="00" marginheight="0"  class=NormalFont>

<form method="post" name="adduser">

<input type="text" name="txtFname" maxlength="50" class="MandatoryTextBox">
<input type="text" name="txtLname" maxlength="50" class="MandatoryTextBox">
<input type=button class="NormalButton" value="Add" id=button6 name=button6 onclick="run();">
<script language="javascript">

function IsEmpty(MyValue)

        {

            if(MyValue.replace(/\s+/g,"").length<=0)

            {

                return true;

            }

            else

            {

                return false;

            }

        }

function run()

{

    if (IsEmpty(adduser.txtFname.value))  

    {

        alert("Enter First Name");

        adduser.txtFname.focus();

    }

    else if (IsEmpty(adduser.txtLname.value))

    {

        alert("Enter Last Name");

        adduser.txtLname.focus();

    }

    else

    {

        adduser.flag.value = "1";
        adduser.action = "adduserprocess.php";

        adduser.submit();    

    }

}

</script>

</form>

</body>
</html>


User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:16 PM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 479



Thanked: 24 times
Dream Kudos: 350
My Contributions
well, you should probably have this in the JS forum... >_>

but IE is notorious for messing up.... so, it's IE's fault =P
User is offlineProfile CardPM
+Quote Post

Ridikule
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:17 PM
Post #3

D.I.C Head
**

Joined: 29 Sep, 2005
Posts: 58



Thanked: 4 times
My Contributions
Try referencing it with the fully qualified name:
document.adduser.txtFname.value

Failing that, you could add the id attribute to your inputs and reference txtFname as document.getElementById('txtFname') rather than document.adduser.txtFname.value

This post has been edited by Ridikule: 27 Aug, 2008 - 08:19 PM
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:20 PM
Post #4

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
PHP isn't scripts, it's server side executable code. So IE or Firefox is irrelevant. The PHP code prepares html that is sent to the browser for viewing. So if there is an error in IE & not Firefox, it must be JavaScript, or some other technology, because the PHP is invisible to the browser.

...plus, after looking at your code, you have no php code. You have the open & end, & nothing in the middle. It's like a bread sandwich, but with PHP.
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:29 PM
Post #5

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
U have no tag in html with name flag
but u r referring a value like
CODE
adduser.flag.value = "1";

That's y it's showing error

even in firefox also if u go to
QUOTE
TOOLS->ERROR CONSOLE

u can see the same error which u r getting in IE.

so first define a tag like flag in html or remove that block from jscript
then it will work fine

wub.gif
User is offlineProfile CardPM
+Quote Post

msvp4u
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:43 PM
Post #6

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 60


My Contributions
QUOTE

even if i remove that adduser.flag.value = "1"; it shows the same error but in firefox as you said there is no error showed in TOOLS->ERROR CONSOLE

User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 08:55 PM
Post #7

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
i tested in my browser and it showing no error and working fine
i did the following change
CODE
else

    {

        //adduser.flag.value = "1";
        adduser.action = "adduserprocess.php";

        adduser.submit();    

    }


and it started working fine without any error

hope u r also doing like tat
wub.gif
User is offlineProfile CardPM
+Quote Post

msvp4u
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 09:21 PM
Post #8

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 60


My Contributions
QUOTE

its working but along with my code in php it is showing error


User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 09:29 PM
Post #9

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
wt error u r getting post the error
i'l try to help crazy.gif
User is offlineProfile CardPM
+Quote Post

msvp4u
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 09:52 PM
Post #10

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 60


My Contributions
QUOTE

I have posted my code please try now.
save the file as .php and try


CODE

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="ButtonStyle.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor=floralwhite leftmargin="0" topmargin="0" marginwidth="00" marginheight="0"  class=NormalFont>

<form method="post" name="adduser">

  <tr>

    <td width="33"><IMG height=33 src="./images/curve.gif" width=33></td>

    <td width="589" bgcolor=#ff8f33 class=NormalFont><FONT color=#315ca0><B>Add User</B></FONT></td>

    <td width="222" valign="bottom" background="./images/search.gif" bgcolor=#ff8f33>

      </td>

    <td width="7" bgcolor=#ff8f33><IMG height=8 src="./images/dot_bg.gif" width=7></td>

  </tr>

  <tr>

    <td colspan="4"><IMG height=1 src="./images/dot_bg.gif" width=7></td>

    <td bgcolor=#ff8f33><IMG height=1 src="./images/dot_bg.gif" width=7></td>

  </tr>

  

<table>

<tr>

<td>
<?php include('frame.php');?>
</td>

          <td width=853 valign=middle align=center>

    <table width=853>

     <tr>

       <td align=center>

       <table border=0 bgcolor=OldLace width=40% class=NormalFont><tr><td align=center>

         <tr>

            <td>

                <LABEL>First Name</LABEL>

            </td>

            <td>

                <input type="text" name="txtFname" maxlength="50" class="MandatoryTextBox">

            </td>    

        </tr>

        <tr>    

            <td>

                <LABEL>Last Name</LABEL>

            </td>

            <td>

                <input type="text" name="txtLname" maxlength="50" class="MandatoryTextBox">

            </td>
        </tr>    

        <tr>
            <td>
                <LABEL>User Type</LABEL>
            </td>
                <td>

                <select name=userlevel class=NormalFont >

                <option value="0">-Select User Level from List-</option>
                <option value ="admin">Admin</option>
                <option value ="user">User</option>
                </select>
                </td>    
        </tr>

        <tr bgcolor=Oldlace>

            <td align="center">

                <input type=button class="NormalButton" value="Add" id=button6 name=add onclick="run();">

            </td>

            <td align="center">

                <input type=Reset class=NormalButton value="Cancel" id=button6 name=button6 onclick=java script:location.href="./userlist.php">

            </td>

        </tr>    

       </td></tr></table>

       </td>

     </tr>

   </table>    

  </td>

</tr>

</table>

<input type ="hidden" name="flag" value="0">
</form>

</body>
<script language="javascript">

function IsEmpty(MyValue)

        {

            if(MyValue.replace(/\s+/g,"").length<=0)

            {

                return true;

            }

            else

            {

                return false;

            }

        }

function run()

{

    if (IsEmpty(adduser.txtFname.value))  

    {

        alert("Enter First Name");

        adduser.txtFname.focus();

    }

    else if (IsEmpty(adduser.txtLname.value))

    {

        alert("Enter Last Name");

        adduser.txtLname.focus();

    }

    else

    {

        adduser.action = "adduserprocess.php";

        adduser.submit();    

    }

}

</script>

</html>



QUOTE

awaiting your response

User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 10:01 PM
Post #11

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
hi msvp4u,
i tried ur code
except as i don't have frame.php and adduserprocess.php
i don't see any errors..
so i guess adduserprocess.php page may have the problem
check that one
User is offlineProfile CardPM
+Quote Post

msvp4u
RE: Php Script Works Fine With Firefox But Not In Internet Explorer
27 Aug, 2008 - 10:13 PM
Post #12

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 60


My Contributions
QUOTE

the following is my adduserprocess.php

CODE

<?php
$db_host = "localhost";// Host name
$db_user = "";// Mysql username
$db_pwd = "";// Mysql password
$db_name = "test";// Database name
$tbl_name=""; // Table name
mysql_connect("$db_host","","");
mysql_select_db($db_name);
$fname = $_POST['txtFname'];
$lname = $_POST['txtLname'];
$userlevel = $_POST['userlevel'];

mysql_query("INSERT INTO loginuser VALUES ('null','$fname','$lname','','','','$userlevel')");

?>
<html>
<script language="javascript">

    alert("<?php echo "$fname $lname";?> Successfully Added");

    location.href ='./userlist.php';

</script>

</html>



i dont think it should have any problem

the error i get is 'adduser.txtFname.value' is null or not object when i press the add button in IE
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:40AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month