mattyd 89 Posting Maven Featured Poster

THIS is what I had originally been working with but does not work for password validation or messages:

`

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<title>jQuery Form Validation</title>

</head>
<body>
<form method = 'post' action = 'jTest1.8.html' id = 'DemoForm' name =   'DemoForm'>
    Username<br />
    <input type="text" id="user_input" name="username" /><br />
    Email<br />
    <input type="text" id="email" name="email" /><br />     
    Password<br />
    <input type="password" id="pass_input" name="password" /><br />
    Confirm Password<br />
    <input type="password" id="v_pass_input" name="v_password" /><br />
    <input type="submit" id="register" value="Register" disabled="disabled" />
</form>
<div id="test">
</div>

<!--Script to disable Submit button --> 
<script>
(function() {
    $('form > input').keyup(function() {

        var empty = false;
        $('form > input').each(function() {
            if ($(this).val() == '') {
                empty = true;
            }
        });

        if (empty) {
            $('#register').attr('disabled', 'disabled');
        } else {
            $('#register').removeAttr('disabled');
        }
    });
})()
</script>

<!--Rules & Messages-->

<!--Username-->



<!--Email-->
      <script src = 'jquery.validate.min.js'></script>    
      <script>
         $('#DemoForm').validate ({
            rules: {
                        'email': {
                                    required:'true',
                                    email: 'true',
                                    }
                      },
                      messages:{
                           'email':{
                           required:'Please submit your email.',
                           email:'Enter a valid email.',
                                       }
                                       },


                                                   });
      </script>


</body>

</html>

<!--Password Validation-->
<script src = 'jquery.validate.min.js'></script>
       <script>
 $('#DemoForm').validate({
           rules: {
               'pass_input': { 
                 required: true,
                    minlength: 8,
                    maxlength: 12,

               } , 

                   'v_pass_input': { 
                     equalTo: "#password",
                     minlength: 8,
                     maxlength: 12
               }


           },
     messages:{
         password: { 
                 required:"the password is required"

               }
     }

       });
         </script>

`

mattyd 89 Posting Maven Featured Poster

I realized I made an error in posting the code here, duplicating code that should not be. That does not solve the error.

I posted the password code twice here in the original post.

mattyd 89 Posting Maven Featured Poster

Hello.

I am rebuilding a registration page and the accompanying form.

I am at a point of implementing jQuery for password validation.

It will not validate nor does it give error messages.

I have researched this on other sites but nothing so far seems to work at all.

Please see code below and thank you in advance:

Note: I do realize I have a form within a form. I do not know if this is good, standard, proper or may be causing problems.

`

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<title>jQuery Form Validation</title>

</head>
<body>
<form method = 'post' action = 'jTest2.3.html' id = 'DemoForm' name = 'DemoForm'>
    Username<br />
    <input type="text" id="user_input" name="username" /><br />
    Email<br />
    <input type="text" id="email" name="email" /><br /> 
    <form id="formCheckPassword">
    <input type="password" class="form-control" name="password" id="password"/>
    <input type="password" class="form-control" name="cfmPassword" id="cfmPassword" />
    <input type="submit" value="submit"/>
 </form>

<form>
<table>
    <tr>
        <td>Password</td>
        <td>
            <label for="pass"></label>
            <input id="pass" name="pass" type="password" value="" />
        </td>
    </tr>
    <tr>
        <td>Password confirm</td>
        <td>
            <label for="pass2"></label>
            <input id="pass2" name="pass2" type="password" value="" />
        </td>
    </tr>
</table>
<input type="submit" name="save" value="Save" />
</form>

</form>

<div id="test">
</div>

<!--Script to disable Submit button --> 
<script>
(function() {
    $('form > input').keyup(function() {

        var empty = false;
        $('form > input').each(function() {
            if ($(this).val() == '') {
                empty = true;
            }
        });

        if (empty) {
            $('#register').attr('disabled', 'disabled');
        } else {
            $('#register').removeAttr('disabled');
        }
    });
})()
</script>

<!--Rules & Messages-->

<!--Username-->



<!--Email-->
      <script src = 'jquery.validate.min.js'></script>    
      $("#formCheckPassword").validate({
           rules: {
               password: { 
                 required: true,
                    minlength: 6,
                    maxlength: 10,

               } , …
mattyd 89 Posting Maven Featured Poster

Hello,

I am experimenting with implementing jQuery to validate my form (I hired a programmer one year ago to do this but it seems she made a mess of it so I am attempting to rebuild it.)

I have multiple fields in my form and I wish many of them to be required and the form unable to be submitted until they are filled out.

This morning I added a script that seems to work. At this experimental stage I have only added an email field, but I will soon add many more fields.

My primary question is: How do I control the submit button from being fired when dealing with multiple fields? In the code, below, you will see the script in the head that controls only the email at this point. I do not at all think I should rewrite that for each field, correct? Can I just seperate the field names by commas to get it to see to each field?

Please see code below:

`

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<title>jQuery Form Validation</title>

<!--Button disable script-->
<script>
    $(document).ready(function(){  

      var checkField;

      //checking the length of the value of message and assigning to a variable(checkField) on load
      checkField = $("input#Email").val().length;  

      var enableDisableButton = function(){         
        if(checkField > 0){
          $('#Submit').removeAttr("disabled");
        } 
        else {
          $('#Submit').attr("disabled","disabled");
        }
      }        

      //calling enableDisableButton() function on load
      enableDisableButton();            

      $('input#Email').keyup(function(){ 
        //checking the length of the value of message and assigning to the variable(checkField) on keyup
        checkField = $("input#Email").val().length;
        //calling enableDisableButton() function on keyup …
mattyd 89 Posting Maven Featured Poster

Hello,

I am wanting to collect the IP address of anyone that visits my site and submits a form (Saving it to my DB).

I have been researching this and have found the following:

`

<?php

    if (getenv('HTTP_X_FORWARDED_FOR')) {
        $pipaddress = getenv('HTTP_X_FORWARDED_FOR');
        $ipaddress = getenv('REMOTE_ADDR');
echo "Your Proxy IP address is : ".$pipaddress. "(via $ipaddress)" ;
    } else {
        $ipaddress = getenv('REMOTE_ADDR');
        echo "Your IP address is : $ipaddress";
    }
?>

`

Of couse, I would modify this code to allow it to post to my DB, not echo it for the User.

Is this a sound method or are there other methods?

Is there anything else in particular that I should be aware of?

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

pritaeas:

Thank you for your reply.

I just watched a YouTube video about this very question that I posted; They said that bound parameters were designed in fact to automatically sanitize input, so I imagine that using both bound parameters and escape strings would be redunadant.

Thanks again,
Matthew

mattyd 89 Posting Maven Featured Poster

Hello,

I am currently using bound parameters in regards to user input on my form. I have read about escape strings also and thought of using both together.

Is this possible and, importantly, is it necessary considering I am already using bound parameters? I would like to use both.

Thank you in advance,
Matthew

mattyd 89 Posting Maven Featured Poster

That worked perfectly. Thank you!

mattyd 89 Posting Maven Featured Poster

Thank you both. I will try your solutions.

mattyd 89 Posting Maven Featured Poster

Hello.

I have one field on my submission form which is for the User's zip code. Originally I had it set to int(5), but when I submit my form with a five digit zip code it only stores 4 of the characters, omitting the first digit.

Example: On the form I type in for zip code: 07084. I then submit it and check the database but what is saved is 7084.

When I submit 07085 it is saved as 7085.

I tried changing it fron an int to a varchar but had the same results.

mattyd 89 Posting Maven Featured Poster

UPDATE:

Attempting to submit the form again three times, all data is now saved correctly using the code posted originally, above. But, I receive the error message: "Thank you for registering - New records created successfully!Access denied for user 'admin'@'localhost' (using password: NO)"

How is it possible that the data is being saved when the error message indicates I do not have access?

This is a puzzle that I will have to look into in the morning.

mattyd 89 Posting Maven Featured Poster

This is what I previously always used but did not think it was MySQLi-compliant:

`

    define('DB_HOST', 'localhost');
    define('DB_NAME', 'hellcircles');
    define('DB_USER', 'diafol');
    define('DB_PASS', 'sillybilly');

`

Is it?

mattyd 89 Posting Maven Featured Poster

Diafol:

The only area of credentials that I changed was the password to "password". All of the rest is the original code as before.

I do not want and cannot have the password actually be "password" - I need a military-grade password which I plan to implement soon.

mattyd 89 Posting Maven Featured Poster

diafol:

I tried as you suggested and received the message:"Connection failed: Access denied for user 'user'@'localhost' (using password: YES)"

mattyd 89 Posting Maven Featured Poster

In the PHP code posted above I have the following:

$password = "********";

The password is being supplied. Nothing in regards to credentials has changed since today when I rebuilt this page for MySQLi and also started to use prepared statements.

mattyd 89 Posting Maven Featured Poster

I re-checked the login credentials - They appear to be correct.

The thing is, the code is set to throw an error if I am unable to connect to the DB and it does not show an error so I assume I am connecting, but, it then shows the password error.

mattyd 89 Posting Maven Featured Poster

diafol:

Hi. I am actually editing the files directly on the hosting site (My machine's server is not even turned on - I rarely use it, only when I am taking online programming classes).

It may very well be an oversite I may with the credentials - I will check that now.

Yes, I am able to login to PHPMyAdmin and am working through it on the hosted site.

mattyd 89 Posting Maven Featured Poster

Hello,

I have just attempted to update my database login page to MySQLi and also use prepared statements but upon submitting a form I receive the error "Access denied for user 'admin'@'localhost' (using password: NO)".

I have been researching this before posting this here but have only come across sites detailing switching server root credentials, etc - I am using a professional hosting site which I pay for (I am not running this on a server on my machine).

I have never received this error message before and I am using the same login credentials as always.

The new code is below.

Any help in the right direction or explanation would be greatly appreciated.

Thank you,
Matthew

`

<?php

$serverName = "localhost";
$userName = "********";
$password = "********";
$dbName = "********";

// Create connection
$conn = new mysqli($serverName, $userName, $password, $dbName);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Prepare and bind
$stmt = $conn->prepare("INSERT INTO Table4 (userName, birthYear, email, password, countries, state, city, zip, company, manager1, manager2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sisssssisss", $userName, $birthYear, $email, $password, $countries, $state, $city, $zip, $company, $manager1, $manager2 );

    $userName = $_POST['user'];
    $birthYear = $_POST['birthYear'];
    $email = $_POST['email'];
    $password =  $_POST['pass'];
    $countries = $_POST ['countries'];
    $state = $_POST ['state'];
    $city =  $_POST['city'];
    $zip =  $_POST['zip'];
    $company = $_POST ['company'];
    $manager1 = $_POST ['manager1'];
    $manager2 = $_POST ['manager2'];
    $stmt->execute();

    echo "Thank you for registering - New records created successfully!";

    $stmt->close();
    $conn->close(); …
mattyd 89 Posting Maven Featured Poster

This is what I am currently using:

`

function NewUser()
{

    $userName = $_POST['user'];
    $birthYear = $_POST['birthYear'];
    $email = $_POST['email'];
    $password =  $_POST['pass'];
    $countries = $_POST ['countries'];
    $state = $_POST ['state'];
    $city =  $_POST['city'];
    $zip =  $_POST['zip'];
    $company = $_POST ['company'];
    $manager1 = $_POST ['manager1'];
    $manager2 = $_POST ['manager2'];

    $query = "INSERT INTO Table4  (userName,birthYear,email,password,countries,state,city,zip,company,manager1,manager2) 
    VALUES ('$userName','$birthYear','$email','$password','$countries','$state','$city','$zip','$company','$manager1','$manager2')";

    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
    echo "YOUR REGISTRATION IS COMPLETED...";
    }
}

`

For example, $userName = $_POST['user'];, looks very different than the example in an above post of:

`

$email = 'pritaeas@example.com';

`

I am assuming that by using prepared statements it is completely different from what I am currently using (as illustrated above).

There is a variable. It can be set to zero for an int. For a string is the variable for a prepared statement set to '' OR a ""? That is my main question.

I am a bit confused by this in general - I have done research but have not yet changed my code to see what works. I do not want to guess at it as it involves security.

Thank you.

mattyd 89 Posting Maven Featured Poster

What I am confused about (And I have seen this in other examples) is contained in the following:

`

// you can now give values to your variables
// whether this happens now, or before the query doesn't matter,
// as long as it happens before execute.
$name = 'pritaeas';
$email = 'pritaeas@example.com';
$dob = '2013-08-30';
$level = 0;

`

In relation to $name, for example, in my MySql at this point nothing like this exists - I have this:

`

$userName = $_POST['user'];

`

I am not manually loading data into the database myself, the User is via a form, so I cannot put something like:

`

$email = 'pritaeas@example.com';

`

The variable must I assume in this case be empty in order to do what I am doing - My question is what do I put there, a zero? I hope this makes sense, if not I will try to clarify more.

Thanks.

mattyd 89 Posting Maven Featured Poster

I do not know if this has already been adressed or if it just me, but I find the insertion of code into a post in a proper manner using the current method to be quite convoluted.

Honestly, I believe it is a malformed feature and could be made and implemented so much easier.

I dread every time I need to post code here - It seems like a hassle and half of the time it never works for me correctly.

Maybe someone can comment on this and point out the best way to go about it - At this point it seems to be a two-step process. That should not be.

Just my opinion.

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

Pritaeas:

Thank you for that link.

My one question: I will not be supplying values in advance, (The User will be doing that via a submitted form) so what do I make the variables in this case, just 0 to begin with before execution? The fields in my table are varchars and ints.

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

I posted earlier today about converting my MySQL to MySQLi - Upon further research I came across the following, Prepared Statements. It seems that this may be a good way to go but I am a bit confused about how to implement it.

I am simply taking User-entered data from a form and adding it to my database. I need to find an example of how to do this using this method.

I found the following example, but it appears to me that it is manually adding it via prepared code. Can anyone please explain explain this to me?

`

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// prepare and bind
$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $firstname, $lastname, $email);

// set parameters and execute
$firstname = "John";
$lastname = "Doe";
$email = "john@example.com";
$stmt->execute();

`

The area of the above code example concerns the section below:

`

// set parameters and execute
    $firstname = "John";
    $lastname = "Doe";
    $email = "john@example.com";
    $stmt->execute();

`
Would I just write one of these statements for each of the pre-existing rows in my table? That snippet looks to me that it is assigning values to the variables in advance. Am I missing something about this?

Any help would be much appreciated.

Thank you,

mattyd 89 Posting Maven Featured Poster

Hello.

I am beginning the process of coverting all of my MySQL to MySQLi.

I have been doing much research on this but find it a bit confusing.

I have two questions at this point regarding the matter:

1) What does it exactly mean to "escape" a string and where does the code for this go? I assume it goes on my page with my database login credentials.

I found the following but find it somewhat hard to interpret:

"We'll use the mysqli_real_escape_string() function. Since it needs a database connection, we'll go ahead and wrap it in its own function. In addition, since we only need to escape strings, we might as well quote the value at the same time:"

`

    function db_quote($value) {
        $connection = db_connect();
        return "'" . mysqli_real_escape_string($connection,$value) . "'";
    }

`
"If we are not sure of the type of value we pass to the database, it's always best to treat it as a string, escape and quote it. Let's look at a common example - form submission. We'll use our previous INSERT query with user input:"

`

    // Quote and escape form submitted values
    $name = db_quote($_POST['username']);
    $email = db_quote($_POST['email']);

    // Insert the values into the database
    $result = db_query("INSERT INTO `users` (`name`,`email`) VALUES (" . $name . "," . $email . ")");

`
2) After I have this set up in my code, how do I properly test that it is indeed working (Without completly wiping …

mattyd 89 Posting Maven Featured Poster

mattster:

Thank you for your reply.

Attached is a screenshot of the index page as it is currently - I would like to have all the text fields grey as some of the others are (with white text).

Also, regarding MySQLi and escape functions: I am about to implement all of that very soon but have not yet as I keep getting held up by other aspects of the site development:

Please see index screenshot: screen1.jpg

mattyd 89 Posting Maven Featured Poster

I am issues involving the CSS for my HTML index page.

I will be honest, I did not write all of the mark-up/code so now I am in discovery/repair mode and find myself a bit lost in regards to the external CSS file.

I have gone over and over it, but cannot find the solution for making all of the fields and elements the color gray (#414141). Some of them are already, most are not (They are white). It is very confusing. I am missing something, somewhere.

Thank you in advance for your time and any help or point in the right direction!
I will post the mark-up/code below:

HTML
`

<!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" xml:lang="en" lang="en">

<head>

<!--Used to clear form upon submit-->
<script>

function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}
</script>

    <title>Sliding Login Panel with jQuery 1.3.2</title>
    <meta name="description" content="Demo of a Sliding Login Panel using jQuery 1.3.2" />
    <meta name="keywords" content=" " />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />    

    <!-- stylesheets -->
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/slide.css" type="text/css" media="screen" />

    <!-- PNG FIX for IE6 -->
    <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 -->
    <!--[if lte IE 6]>
        <script type="text/javascript" src="js/pngfix/supersleight-min.js"></script>
    <![endif]-->

    <!-- jQuery Slide -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <!-- Sliding effect -->
    <script src="js/slide.js" type="text/javascript"></script>
    <script>
      function validateEmail(email) { 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
      } 

      $(document).ready(function() {
        $('.error_message').hide();
        $('#first_val').val(Math.floor(Math.random()*11));
        $('#second_val').val(Math.floor(Math.random()*11));
        $('#loadingGif').hide(); …
mattyd 89 Posting Maven Featured Poster

JorgeM,

Hi. I implemented your suggestion to fix the slide-down problem - It worked perfectly. Thank you so much for your kind assistance!

Matthew

mattyd 89 Posting Maven Featured Poster

JorgeM,

Thank you for this explanation and also about other resources not loading. I will look into all of this in the morning and post the results here.

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

I cannot get this to work properly - I put .html { overflow-y: scroll } in my css file and <div id = "html"> in my index page.

I am still struggling to understand CSS completely - I experiment and some of the results are odd, unexpected.

I do not like hacking at my mark-up/code but sometimes that is the only thing that works and in turn teaches me.

Am I doing something wrong with this particular example?

mattyd 89 Posting Maven Featured Poster

JorgeM:

When you say my "html element" are you referring to something in CSS or directly in my HTML mark-up?

Thanks,
M

mattyd 89 Posting Maven Featured Poster

JorgeM:

I shall try that suggestion - I pray it works because this little issue driving me crazy.

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

Showman13:

Yes, I think that makes sense but I am not happy with that outcome or appearance of that.

Is there any way that you know of to modify this? I suppose I will need the scroll bar for the finished page, but I do not want it to jump like that - It needs to glide down smooth.

I imagine I can somehow shift the entire bar and registration contents over (left) to accompany the bar so it does not jump left, allowing space for the vertical scroll-bar by default. Does that make sense?

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

There is an issue with a page I am developing that I just noticed.

Please take a look at the page: http://redlinedown.com/index700.html#

On the top, black panel bar, notice "Log In | Register" in blue > Select this link and watch as the bar opens and drops down.

When it completes dropping down to display the registration area it immediately jumps (I would approximate) 1-3 pixels to the left.

Would anyone know why this behavior may exist? Any hints or pointers would be greatly appreciated.

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

What I mean by reload is to use the back button or the refresh icon for the given page.

I have multiple fields in a form - Upon reload I wish to clear all fields except for one.

I am easily able to clear all fields by using onload and onUnload but that unfortunately clears all fields.

mattyd 89 Posting Maven Featured Poster

This is the code for the .html (Same code as when I save it as .php). Please excuse the messy code, I am in the middle of many things concerning this page.

`

<!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" xml:lang="en" lang="en">

<head>

<!--Used to clear form upon submit-->
<script>
function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}
</script>

    <title>Sliding Login Panel with jQuery 1.3.2</title>
    <meta name="description" content="Demo of a Sliding Login Panel using jQuery 1.3.2" />
    <meta name="keywords" content=" " />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />    

    <!-- stylesheets -->
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/slide.css" type="text/css" media="screen" />

    <!-- PNG FIX for IE6 -->
    <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 -->
    <!--[if lte IE 6]>
        <script type="text/javascript" src="js/pngfix/supersleight-min.js"></script>
    <![endif]-->

    <!-- jQuery Slide -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <!-- Sliding effect -->
    <script src="js/slide.js" type="text/javascript"></script>
    <script>
      function validateEmail(email) { 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
      } 


      $(document).ready(function() {
        $('.error_message').hide();
        $('#first_val').val(Math.floor(Math.random()*11));
        $('#second_val').val(Math.floor(Math.random()*11));
        $('#loadingGif').hide();

      $('.bt_register').click(function(e){
        $('#loadingGif').show();

        e.preventDefault();
        $('.error_message').hide();
        $('#email_error').html("Please enter a valid email.");
        $('#user_error').html('Required');

        error=false;

        if ($('#user').val().length<1) {
          error=true;
          $('#user_error').show();
         }
         if ($('#email').val().length<1 || !validateEmail($('#email').val())) {
          error=true;
          $('#email_error').show();
         }
         if ($('#pass').val().length<8) {
          error=true;
          $('#pass_error').show();
         }
         if ($('#city').val().length<1) {
          error=true;
          $('#city_error').show();
         }
         if ($('#pass').val() != $('#confirmpass').val()) {
            error=true;
            $('#confirmpass_error').show();

          }

          var disallowed_characters=/www|http|@|com|\./;

          if (disallowed_characters.test($('#city').val())) {
            error=true;
            $('#city_error').show();
          }
          if (disallowed_characters.test($('#company').val())) {
            error=true;
            $('#company_error').show();
          }

          $.getJSON('ajax.php?username='+$('#user').val(), function(data) {
            if (data.error) {
                error=true;
                alert('An error has occured');
            } else {
                if (!data.isUnique) {
                    error=true;
                    $('#user_error').html('This username is already …
mattyd 89 Posting Maven Featured Poster

I have my files on a hosting service company running Apache.

Do you mean that in order for me to see them I need to be running a local server? I have a server on my machine but that does not help really - I need these files to be live on the Web via the hosting company.

mattyd 89 Posting Maven Featured Poster

I apologize if I asked this question before - I may have.

I am hearing two sides to this issue:

  1. .php files WILL display in a web browser
  2. .php files will NEVER display in a web browser

I find this very confusing. I am watching video tutorials and people are creating then saving a file as .php (which primarily contains html with a bit of php also). They then display the .php page in their browser.

When I try renaming a .html file to .php and load it, the entire page is blank and no source code is available.

I realize that .php is server-side, but how are people getting this to run in this manner?

I need to be able to convert a .html file to .php and run it.

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

I added that code.

The field itself (Not the input value) disappeared and code displayed on the page.

I will have to play with this to try to get it to work.

mattyd 89 Posting Maven Featured Poster

diafol:

I will try your example right now.

Thank you.

mattyd 89 Posting Maven Featured Poster

Hello.

I have one question.

I have a form which I wish to clear all fields upon refresh/reload (except one field).

Using onload and onunload, all fields are cleared but I need to retain one field upon a User doing this action.

Is there a method where I can perhaps loop through all the fields, choosing those I wish to clear, and the one I want to retain?

Thank you in advance for any assistance or advice.

Matthew

mattyd 89 Posting Maven Featured Poster

Dave,

I generally do not like to use what might be considered work-arounds (For various reasons) but in this case it seems just fine. Thanks again!

Matthew

mattyd 89 Posting Maven Featured Poster

DaveAmour:

Actually your hack worked wonderfully. Thank you so much for taking the time with this for me. I appreciate it!

Matthew

mattyd 89 Posting Maven Featured Poster

The link to the site is as follows:

Click Here

Please note, it is in a dev state and far from finished.

Thank you to anyone that takes a look and can give me a pointer in the right direction.

Matthew

mattyd 89 Posting Maven Featured Poster

JorgeM:

I believe this may be relative, but I am not exactly sure (Note: Last year I hired a programmer to develop one feature of my site and I fear she made many changes that I am just becoming aware of now - No detailed documentation was provided by her as to the changes. That was my fault for not thinking to request it. Lesson learned!)

`

#panel .content label {
    float: left;
    padding-top: 8px;
    clear: both;
    width: 280px;
    display: block;
}

`

Also, This CSS has never been edited by me yet at this point.

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

DaveAmour:

Thank you for your reply.

I do not think it requires a for attribute - It never had one. It is just a simple text label set to display over a dropdown list.

Source control: I have no automated form of source control - I rely on manual back-ups of working code; When all is working I back that file up and start a new development file to work with. In this case, unfortunately, I do not believe I have such a back-up file.

mattyd 89 Posting Maven Featured Poster

Hello.

I am having a small problem involving a text label not displaying correctly over a field.

It was fine until about a week ago; I believe I must have changed something and now I do not remember what I did that is causing this error.

The State text label should display over the dropdown but no matter what I try I cannot get it to render in this manner.

Here is code related to this area in question:

`

<!--City Field-->
<label type="grey" for="email">City:</label>
<input type="field" type="text" name="city" id="city" size="23" />

<!--State Field-->   
<label>State:</label>
<select name="state" id="state">

`

Please see attached screenshot.

Thank you in advance!
Matthew !

dd1.jpg

mattyd 89 Posting Maven Featured Poster

Hello:

I am getting a parse error while running a file on my server on my home machine:

Parse error: syntax error, unexpected end of file

I have been researching this for a few hours now but have had no results to overcome this error.

In the editor it is indicating the last line, </html>, but I am sure that last line is correct and the error must lie somewhere in the code above that.

Any advice or pointers in the right direction would be much appreciated.

`

    <!-- The tab on top -->  
    <div class="tab">
        <ul class="login">
            <li class="left">&nbsp;</li>
            <li>Hello Guest!</li>
            <li class="sep">|</li>
            <li id="toggle"></li>
                <a id="open" class="open" href="#">Log In | Register</a>
                <a id="close" style="display: none;" class="close" href="#">Close Panel</a>                       
            <li class="right">&nbsp;</li>
        </ul> 


    </div> <!-- / top --> 
</div> <!--panel -->

    <div id="container">
        <div id="content" style="padding-top:100px;">
        </div><!-- /content -->       
    </div><!-- /container -->
</body>
</html>

`

mattyd 89 Posting Maven Featured Poster

Part of the reason I am attempting the .php conversion is in order to use include files- I started that this morning and it did not work.

I am sorry for the lengthy and sloppy code - I am in the process of cleaning it up.

Thanks, broj1 :)

mattyd 89 Posting Maven Featured Poster

I inserted

`

<?php
    ini_set('display_errors',1);
    error_reporting(E_ALL);?>

`

And ran it - Nothing displayed. The page jumped automatically to index.html.

mattyd 89 Posting Maven Featured Poster

broj1:

I will switch error reporting on now.

Here is the code for index.php which will not display (But instead loads index.html - I have no idea why it would do that)

`

<!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" xml:lang="en" lang="en">

<head>

<!--Used to clear form upon submit-->
<script>
function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}
</script>




    <title>Sliding Login Panel with jQuery 1.3.2</title>
    <meta name="description" content="Demo of a Sliding Login Panel using jQuery 1.3.2" />
    <meta name="keywords" content=" " />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />    

    <!-- stylesheets -->
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/slide.css" type="text/css" media="screen" />

    <!-- PNG FIX for IE6 -->
    <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 -->
    <!--[if lte IE 6]>
        <script type="text/javascript" src="js/pngfix/supersleight-min.js"></script>
    <![endif]-->

    <!-- jQuery Slide -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <!-- Sliding effect -->
    <script src="js/slide.js" type="text/javascript"></script>
    <script>
      function validateEmail(email) { 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
      } 


      $(document).ready(function() {
        $('.error_message').hide();
        $('#first_val').val(Math.floor(Math.random()*11));
        $('#second_val').val(Math.floor(Math.random()*11));
        $('#loadingGif').hide();

      $('.bt_register').click(function(e){
        $('#loadingGif').show();

        e.preventDefault();
        $('.error_message').hide();
        $('#email_error').html("Please enter a valid email.");
        $('#user_error').html('Required');

        error=false;

        if ($('#user').val().length<1) {
          error=true;
          $('#user_error').show();
         }
         if ($('#email').val().length<1 || !validateEmail($('#email').val())) {
          error=true;
          $('#email_error').show();
         }
         if ($('#pass').val().length<8) {
          error=true;
          $('#pass_error').show();
         }
         if ($('#city').val().length<1) {
          error=true;
          $('#city_error').show();
         }
         if ($('#pass').val() != $('#confirmpass').val()) {
            error=true;
            $('#confirmpass_error').show();

          }

          var disallowed_characters=/www|http|@|com|\./;

          if (disallowed_characters.test($('#city').val())) {
            error=true;
            $('#city_error').show();
          }
          if (disallowed_characters.test($('#company').val())) {
            error=true;
            $('#company_error').show();
          }

          $.getJSON('ajax.php?username='+$('#user').val(), function(data) {
            if (data.error) {
                error=true;
                alert('An error has occured');
            } else {
                if (!data.isUnique) {
                    error=true;
                    $('#user_error').html('This username is already …