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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2013
    Location
    Texas, USA
    Posts
    35
    Thanks
    5
    Thanked 0 Times in 0 Posts

    form not sending

    I have a form in html that is sending to my php to login. The form, when hitting submit, does nothing. If you hover over the button it shows the correct path that it should be posting to. It asks to save the password just like any other typical form as well, so I'm not sure why it's not going through. I do have a html5 form shim on, but it doesn't submit in FF/Chrome either (https://github.com/dsheiko/HTML5-Form-Shim). This is the HTML for the form (sorry if should have posted in html instead):

    PHP Code:
    <form method="post"  action="classes/class.registration.php" id="register_form" class="register_form" data-custom-validation="true">
                    <
    fieldset id="logininfo">
                        <
    label for="email">Email: </label>
                        <
    input name="email" id="email" type="email" placeholder="enter email" required="required" />
    ....
    </
    form
    and this is what its sending to (yes its not a real class)
    PHP Code:
    <?php
    //require necessary files
    require('../config/dbconfig.php');
    include(
    'class.mysqli.php');
    $checkValid false;

    if (isset(
    $_POST['submit']))
    {
        
    //check for blank fields
        
    if ($_POST['email'] == '' || $_POST['email'] == null ||
            
    $_POST['pass2'] == '' || $_POST['pass2'] == null ||
            
    $_POST['regcode'] == '' || $_POST['regcode'] == null ||
            
    $_POST['firstname'] == '' || $_POST['firstname'] == null ||
            
    $_POST['lastname'] == '' || $_POST['lastname'] == null ||
            
    $_POST['country'] == '' || $_POST['country'] == null ||
            
    $_POST['street'] == '' || $_POST['street'] == null ||
            
    $_POST['city'] == '' || $_POST['city'] == null ||
            
    $_POST['state'] == '' || $_POST['state'] == null ||
            
    $_POST['zip'] == '' || $_POST['zip'] == null ||
            
    $_POST['lang'] == '' || $_POST['lang'] == null ||
            
    $_POST['tzone'] == '' || $_POST['tzone'] == null ||
            
    $_POST['bday'] == '' || $_POST['bday'] == null)
        {
            
    header('location:register.php?error=blank');
            exit;
        }

        
    //hash the password
        
    $hash hash('sha256'$_POST['pass1']);

        
    //create salt for password
        
    $salt createSalt();

        
    //add salt to pass
        
    $hash hash('sha256'$salt $hash);

        
    //connect to the database
        
    $db = new db("mysql:host=$db_host;dbname=$db_name"$db_user$db_pass);

        
    //double check username availability before entering in db//if disabled javascript or error
        //set up bind variables
        
    $bind = array(
            
    ":uemail" => "$_POST['email']"
        
    );

        
    //query database
        
    $results $db->select('users','email=:uemail',$bind,'email','','');

        
    //check results for email
        
    if (count($results) > 0) {
            foreach(
    $results as $row)
            {
                if (
    $row['regcode'] == null)
                {
                    
    header('location:register.php?error=email');
                    exit;
                }
                if (
    $row['regcode'] == $_POST['regcode'])
                {
                    
    $checkValid true;
                }
            }
        }

        
    //set up array to insert
        
    $insVal = array(
            
    "email" => $_POST['email'],
            
    "password" => $hash,
            
    "salt" => $salt,
            
    "firstname" => $_POST['firstname'],
            
    "lastname" => $_POST['lastname'],
            
    "country" => $_POST['country'],
            
    "street" => $_POST['street'],
            
    "city" => $_POST['city'],
            
    "state" => $_POST['state'],
            
    "zip" => $_POST['zip'],
            
    "joined" => date("Y-m-d H:i:s"),
            
    "lastlogin" => date("Y-m-d H:i:s"),
            
    "active" => 1,
            
    "staff" => 0,
            
    "department" => null,
            
    "position" => "user",
            
    "language" => $_POST['lang'],
            
    "timezone" => $_POST['tzone'],
            
    "birthday" => $_POST['bday'],
            
    "regcode" => null
        
    );
        
    //var_dump($insVal);

        //insert into database
        
    if ($checkValid == true)
        {
            
    $putIn $db->insert("users"$insVal);
        }else
        {
            
    header('location:register.php?error=regcode');
        }

        
    //var_dump($insert);
        //check results and return    
        
    if ($putIn == 1)
        {
            
    header('location:success_register.php');
        } else
        {
            
    header('location:register.php?error=dberror');
            exit;
        }
    }else
    {
        
    header('location:register.php?error=blank');
    }

    //creates a 3 character sequence, hash pass again
    function createSalt()
    {    
        
    $string md5(uniqid(rand(), true));    
        return 
    substr($string03);
    }
    ?>
    Also going to the php file itself throws a 500 server error. I took out the includes/requires at the top and tried again, and it still does the error, which I dont see why as it should just call the header back since the post is blank.
    I also didn't notice it sending anything at all in firefox. If you want you can see at:
    http://imengine.gofreeserve.com/fileshare/register.php
    Last edited by gkjr1; 01-25-2013 at 10:47 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,310
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by gkjr1 View Post
    The form, when hitting submit, does nothing.
    Where do I start?

    First of all, stop checking for the submit button

    Quote Originally Posted by gkjr1 View Post
    I do have a html5 form shim on, but it doesn't submit in FF/Chrome either (https://github.com/dsheiko/HTML5-Form-Shim).
    From what I could make out thats a jquery plugin right? Sounds like it could be interfering with the browser but I'm no JS / JQuery expert.

    Quote Originally Posted by gkjr1 View Post
    PHP Code:
    if (isset($_POST['submit']))

    GET RID OF THAT!!!

    Seriously, it's awful and will annoy and frustrate your IE users.

    Quote Originally Posted by gkjr1 View Post
    Also going to the php file itself throws a 500 server error.
    So you need to look at your webserver / php error logs.

    Quote Originally Posted by gkjr1 View Post
    I also didn't notice it sending anything at all in firefox. If you want you can see at:
    http://imengine.gofreeserve.com/fileshare/register.php
    If you're going to ask people to look at it and test it you at least need to give them things like the registration code otherwise you're not going to get a lot of help if we can't test it
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    gkjr1 (01-26-2013)

  • #3
    New Coder
    Join Date
    Jan 2013
    Location
    Texas, USA
    Posts
    35
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post

    If you're going to ask people to look at it and test it you at least need to give them things like the registration code otherwise you're not going to get a lot of help if we can't test it
    Sorry about that. Been sick. it doesnt matter what you put in the form. Just keep going with characters until a green arrow shows up, but to be exact one some things:

    email needs an email type, password is 6 characters and both have to match, reg code is 16 characters, zip code is 5 numbers, and the rest shouldn't need more than 2 characters.

    I took out the submit and yes it is a jquery plugin. There isn't another way I know of to use validation like the rest of the good browsers. The checks still work per browser, at least visually, with those that support html5 form validation. I've looked through the plugin and don't see anything, but I could very possibly be missing something.

    Still in the same boat though, no go.
    Last edited by gkjr1; 01-26-2013 at 04:09 AM.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,618
    Thanks
    0
    Thanked 645 Times in 635 Posts
    With JavaScript enabled the form will not submit - it also insists on rejecting valid values entered into several of the fields - such as not allowing one character surnames (I know of people with surnames like that), three character state codes and no state code at all are valid depending on which country you are in etc.

    With JavaScript disabled it submits and presents http://imengine.gofreeserve.com/fileshare/classes/class.registration.php as a blank page with no code in it whatsoever.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    gkjr1 (01-26-2013)

  • #5
    New Coder
    Join Date
    Jan 2013
    Location
    Texas, USA
    Posts
    35
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    With JavaScript enabled the form will not submit - it also insists on rejecting valid values entered into several of the fields - such as not allowing one character surnames (I know of people with surnames like that), three character state codes and no state code at all are valid depending on which country you are in etc.

    With JavaScript disabled it submits and presents http://imengine.gofreeserve.com/fileshare/classes/class.registration.php as a blank page with no code in it whatsoever.
    The validation isn't completely done as I'm still going to add in the dynamic provinces/states/postal codes, but I do appreciate you pointing that out for me to keep in mind.

    Weird that it will submit w/o javascript on. Is that typical of all forms, or most likely the validation code I'm using is stopping it? Also which browser? The other page is blank because it wasn't done, and disabling javascript (it's required on the site, eventually when complete) kills some checks clientside, and I haven't returned the errors in the php check yet because I couldn't get there. xD

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Its typical of all forms that the javascript is interfering with. JS should be the very last thing added. Make sure it works and is validated properly server side, then add the splash of JS for the fancy.

    This has syntactical errors within it:
    PHP Code:
        $bind = array(
            
    ":uemail" => "$_POST['email']"
        
    ); 
    That is invalid. That should be:
    PHP Code:
        $bind = array(
            
    ":uemail" => $_POST['email']
        ); 
    There is never a reason to require JS.
    You shouldn't be developing code on a live server. Download an apache, php and mysql environment and install it (or a package like the wamp or many other flavours), and test there. At the minimum get ahold of the php.exe which can execute a lint check against the code, which is what I did to see the T_ENCAPSED_AND_WHITESPACE error on that line above.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    gkjr1 (01-26-2013)

  • #7
    New Coder
    Join Date
    Jan 2013
    Location
    Texas, USA
    Posts
    35
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Its typical of all forms that the javascript is interfering with. JS should be the very last thing added. Make sure it works and is validated properly server side, then add the splash of JS for the fancy.

    This has syntactical errors within it:
    PHP Code:
        $bind = array(
            
    ":uemail" => "$_POST['email']"
        
    ); 
    That is invalid. That should be:
    PHP Code:
        $bind = array(
            
    ":uemail" => $_POST['email']
        ); 
    There is never a reason to require JS.
    You shouldn't be developing code on a live server. Download an apache, php and mysql environment and install it (or a package like the wamp or many other flavours), and test there. At the minimum get ahold of the php.exe which can execute a lint check against the code, which is what I did to see the T_ENCAPSED_AND_WHITESPACE error on that line above.
    I got it working. It was hung up on the way I was updating the db. I understand you NEVER have to have js, but I was using it no matter what for other things like folder tree stuctures, ect.

    All I was trying to do was let html5 do it's pretty validation on IE as well as older browser versions that don't support it, so the majority of regular users on IE 9 could enjoy it, and save me some time. It isn't a requirement I know, just never ran into a js for input fields interrupt a submit button action on a form.


  •  

    Posting Permissions

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