Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Firefox Javascripting Error

    Hello,
    I am very new to coding; however, I have successfully taught myself some PHP to use with MYSQL and I already knew html and css. I do not know very much javascript. I run a website that contains a member's only section in which members may post to a thread. I have compiled this post.php page to insert the content of the post into the database and then forward on some information in a form, while autoloading the user.php page. Basically, it has a hidden form containing the username and password of the user which then will get automatically resubmitted. It works perfectly in both IE and Safari; however, it does not work in Firefox. Rather, it inserts the content into my database; however, it does not execute the javascript to POST the form. Here is my script:

    <!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=ISO-8859-1" />
    <title>post</title>
    <?
    include 'connect.php';
    ?>
    <?php
    $ip = $_SERVER['REMOTE_ADDR'];
    $user=$_POST['user'];
    $password = $_POST['password'];
    $Message=$_POST['Message'];
    $forum=$_POST['forum'];
    mysql_query("INSERT INTO forum (ip, date, user, comment, forum) VALUES ('$ip', NOW(),'$user','$Message','$forum')");
    $action = "Post to $forum";
    mysql_query("INSERT INTO log (ip, date, user, password, action) VALUES ('$ip', NOW(), '$user', '$password', '$action')");
    ?>
    <form action="user.php" id="posting" method="post">
    <input name="user" type="hidden" value="<? echo $_POST['user'];?>" />
    <input name="password" type="hidden" value="<? echo $_POST['password'];?>" />
    </form>
    <script language="JavaScript" type="text/javascript">
    <!--
    document.getElementById('posting').submit();
    //-->
    </script>
    </head>

    <body onLoad="document.form.submit()">
    </body>
    </html>

    Any help is greatly appreciated,
    Thanks!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I'm not sure why are you using javascript to login the user. Why not just use sessions that whole their username. Why do you have to post to user.php anyways? Doing it this way isn't very secure and it also fails if javascript is disabled. Its failing btw because the DOM isn't yet created. You probably get an error in the error console. Its under the tools menu.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    Yes, and you can't put a form in the head section of a page, so validity would be very much an issue too
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #4
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would have loved to use sessions to hold the username, but unfortunately, I have absolutely no idea how to do that. Any advice?
    thanks, Matt

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I find it a bit hard to understand that you taught yourself php and mysql but you skipped over something simple like sessions. Tutorial here: http://www.tizag.com/phpT/phpsessions.php
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •