Results 1 to 7 of 7

Thread: PHP Forms in Firefox

  1. #1
    Join Date
    Feb 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Forms in Firefox

    I have two forms on my website, they both use 1 javascript method on submit and 1 PHP action, the code can be seen below

    Form 1
    <form onsubmit="return validate_signUp();" action="signUp.php" enctype="x-www-form-encoded" method="post" target="_self" name="signUp">

    Form 2
    <form onsubmit="return validate_Comments();" action="commentsPost.php" enctype="x-www-form-encoded" method="post" target="_self" name="CommentsForm">

    They both work fine on IE but on Firefox none of them seem to work, the fields dont get validated and the incorrect php are being used

    Why is this?? Any help would be much appreciated

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Mind if I see your PHP and Javascript?
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    For Firefox, go to Tools -> Error Console - most likely it is a Javascript error. There you can see the error messages and have some lead into what is happening.

  4. #4
    Join Date
    Feb 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The 2 Java script functions are below;
    validate_signUp()
    <script Language ="JavaScript">
    function validate_signUp()
    {
    var illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\]\$\\&\%\*\`\_\@\\!\-\?\|]/
    var illegalEmailChars= /[ \(\)\<\>\,\;\:\\\/\"\[\]\$\\&\%\*\`\\!\-\?\|]/
    var name = document.signUp.name.value;
    var mail = document.signUp.mail.value;
    atpos=mail.indexOf("@");
    dotpos=mail.lastIndexOf(".");

    valid = true; for (var i = 0; i < name.length; i++)
    {
    var ch = name.substring(i, i + 1);
    if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' '&& ch != '.')
    {
    valid = false;
    }
    }
    if (name.length<1)
    {
    valid = false;
    }
    if (!valid)
    {
    alert("Please ammend your name");
    }

    if( (atpos<1||dotpos-atpos<2)||( document.signUp.mail.value.match(illegalEmailChars) ) )

    {
    alert("Please ammend your email address");
    valid = false;
    }

    return valid;
    }


    validate_Comments()

    function validate_Comments()
    {
    var illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\]\$\\&\%\*\`\_\@\\!\-\?\|]/
    var illegalEmailChars= /[ \(\)\<\>\,\;\:\\\/\"\[\]\$\\&\%\*\`\\!\-\?\|]/
    var Cname = document.CommentsForm.commentsName.value;
    var Cmail = document.CommentsForm.commentsMail.value;
    var comments = document.CommentsForm.comments.value;

    atpos= Cmail.indexOf("@");
    dotpos= Cmail.lastIndexOf(".");

    valid = true; for (var i = 0; i < Cname.length; i++)
    {
    var ch = Cname.substring(i, i + 1);
    if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' '&& ch != '.')
    {
    valid = false;
    }
    }
    if (Cname.length<1)
    {
    valid = false;
    }
    if (!valid)
    {
    alert("Please ammend your name");

    }

    if( (atpos<1||dotpos-atpos<2)||( document.CommentsForm.commentsMail.value.match(illegalEmailChars) ) )

    {
    alert("Please ammend your email address");
    CommentsForm.commentsMail.focus();

    valid = false;
    }
    if (comments <5)
    {
    alert("Please enter your comment");
    CommentsForm.comments.focus();
    valid = false

    }

    return valid;
    }

    The PHP Scripts
    commentsPost.php
    <?php


    include("header.htm");
    // Receiving variables
    @$pfw_ip= $_SERVER['REMOTE_ADDR'];
    @$name = addslashes($_POST['commentsName']);
    @$mail = addslashes($_POST['commentsMail']);
    @$mail = addslashes($_POST['comments']);

    // Validation
    //Sending Email to form owner
    $pfw_header = "From: $mail\n"
    . "Reply-To: $mail\n";
    $pfw_subject = "New Comment";
    $pfw_email_to = "******";
    $pfw_message = "Visitor's IP: $pfw_ip\n"
    . "name: $commentsName\n"
    . "mail: $commentsMain\n"
    . "comment: $comments\n"
    . " ";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

    echo("
    <p align='center'><b><font face='Verdana' size='3' color='#FFFFFF'>Thank you for leaving your comments. They will be moderated and added to this page if accepted</font></CENTER></b></p>");
    ?>

    signUp.php
    <?php


    include("header.htm");
    // Receiving variables
    @$pfw_ip= $_SERVER['REMOTE_ADDR'];
    @$name = addslashes($_POST['name']);
    @$mail = addslashes($_POST['mail']);

    // Validation
    //Sending Email to form owner
    $pfw_header = "From: $mail\n"
    . "Reply-To: $mail\n";
    $pfw_subject = "New Special Offers Member";
    $pfw_email_to = "****, *****";
    $pfw_message = "Visitor's IP: $pfw_ip\n"
    . "name: $name\n"
    . "mail: $mail\n"
    . " ";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

    echo("
    <p align='center'><b><font face='Verdana' size='3' color='#FFFFFF'>Thank you for signing up. Below is your voucher.<br><CENTER> <img src='#####''></font></CENTER></b></p>");
    ?>

  5. #5
    Join Date
    Feb 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And i did check the error console it says the form i am using is undefined but I have defined it

  6. #6
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    Then it is a JavaScript/HTML error...

    When it comes to debugging, one thing to bear in mind - don't blame the platform, look at your own code. Don't blame FireFox, look at your code...

    If I remember correctly, FireFox and IE has some slight variations in their DOM model, but it has been a long time.

    Here's a link from a quick google (your best internet pal ever)
    http://www.webmasterworld.com/forum91/3400.htm

    Hope this helps.

  7. #7
    Join Date
    Feb 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That link seemed to provide me with the route to the problem, and with afew minor tweeks it is working fine.

    Thanks for the help lads much appreciated

Bookmarks

Posting Permissions

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