mattyd 89 Posting Maven Featured Poster

What is happening now: I run index.php and it begins to load but then instead loads index.html. Why would this happen?

This is the .php link which then automatically switches to my index holding page, index.html:
http://www.redlinedown.com/index.php

mattyd 89 Posting Maven Featured Poster

broj1:

I created a new test.php file with the code:

`

    <?php
    phpinfo();
    ?>

`

I recieved a huge list as a response containing much information I do not understand at all.

So, I guess .php files do work/display, yet the one I created earlier, index.php, was blank when loaded. I am going to retry that again now.

mattyd 89 Posting Maven Featured Poster

broj:

I have tried changing the index page to .php earlier - I ran it in the browser and it was blank.

On another forum someone else said it was impossible to do this, run a .php in a browser. Now I am very confused.

Thank you for your help!

Matthew

mattyd 89 Posting Maven Featured Poster

broj1:

Thanks for your reply.

Yes, my index page contains PHP code already (but has a .html extension)

I am using GoDaddy as my hosting service and I believe they are using Apache servers.

mattyd 89 Posting Maven Featured Poster

I am working on a project and have been doing some research.

One thing I have noticed are tutorials calling for saving the index file in .php.

I tried this and when loading the file, the result is a blank page.

I do not understand why people are suggesting this or, perhaps, I am mising something.

Any suggestions or advice you be much appreciated.

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

Generally I do not like work-arounds. It seems sloppy to me and it usually does not get to the root issue, which is something all developers should be thriving for in my opinion.

I am not sure what to do at this point. I think I will just try working on it again in the morning. I have been at this since 6:00am today and am worn out by it.

Thanks for your advice, diafol.

mattyd 89 Posting Maven Featured Poster

diafol:

I am just trying to clear all fields on a form after submission when a back button is clicked or when the form page is refreshed. I am not attempting to over-ride a user's browser preferences.

It worked before but broke today, the password fields not clearing upon refresh.

mattyd 89 Posting Maven Featured Poster

I just tried this in Internet Explorer - I recieved different results: This time instead of saving and displaying the 2 password fields it saves and displays the city and company fields. Auto-fill is set to off and history is cleared.

mattyd 89 Posting Maven Featured Poster

diafol:

I have adjusted the auto-complete for my browser, Firefox, to off. I have cleared the cache. I do not think it is related.

I am very confused by this. This cropped up this morning and I made no apparent changes to the code.

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

``

<!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="jquery, sliding, toggle, slideUp, slideDown, login, login form, register" />
    <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 taken.');
                     $('#user_error').show();
                }
            }


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

I have been cleaning up my server of useless files - I double-checked each file to make sure it was definitely unneeded, so nothing I removed is causing this issue.

This is the bug; It involves a form:

  • I filled out a form and submitted it to the DB - This works fine (Important: I enter a 9-digit password and confirm it before submitting) All form data is saved correctly to the DB as entered.
  • The bug: I am using onUnload to fully clear the form when I reload the page or use the back button - This has been working perfectly until a few minutes ago.
  • What is happening now: When I refresh/back button the page not only is the first, unconfirmed password field still filled BUT the login password field is now filled as well (I have not touched any of this code today so I am not sure what is causing this)
  • When I refresh the page, the password field and login password field mometarily clear but then reload and display filled again.
  • I tried clearing my browser cache but it still happens.
  • I even closed the main page where this is happening and then reopened it - Upon doing this the password fields were both still filled (That makes no sense to me at all)
  • One last thing I tried: I manually cleared the form of all password data - Instead of putting my usual 9 character password into the fields I put in 16 characters …
mattyd 89 Posting Maven Featured Poster

hericles:

Thank you for your reply.

I am using this file on a web hosting service, yes, a live server - Although the site is not actually live yet or complete, it is available on the Web.

What I mean is, I changed the suffix for the file containing the form to .php (from .html). When I reloaded the page/form it was blank. I assumed this was because it is now a .php file and the page was now essentially hidden.

I made the changes on the company's server.

I do not have direct access to the root of the server to change anything.

I hope that I am making sense wth this...

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

Hello.

I am attempting to add a Google reCaptcha to my form. This form is located on an .html page, but I am reading documentation that states I should rename the page with a .php suffix.

I did this and reloaded the page and, obviously, nothing was displayed at all.

I am a bit confused. In using this I will be dealing with secret keys which will need to be hidden (They would be displayed openly in an .html document).

I just wondered if anyone had any experience with reCaptcha or any of the issues of renaming a page .php.

At this point I am very confused about the entire process of implementing this.

Thank you in advance!

mattyd 89 Posting Maven Featured Poster

Much thanks to all of you for your input. I am marking this thread solved. I may have further questions in the future.

mattyd 89 Posting Maven Featured Poster

Hello.

I am beginning the process of implementing password encryption for User's on my future site (The site is not live or available yet).

I have been reading up on hashing passwords and storing them in the database.

My question are as follows:

  • I believe it has said that once hashed, the password is stored as plain text and not reversable - I take this to mean that it cannot be viewed by me in its original state, the original User password. Is this correct?
  • The online PHP manual suggests using password_hash() or crypt(); This is an aspect of programming/PHP which is new to me. Do I have to include any sort of files or set-up server side in order to get this to function?
  • When a password is hashed, is it always the same character length? I ask this as I would need to know a length in order to store it correctly in the DB.

Any other input would help greatly.

Thank you in advance!
Matthew

mattyd 89 Posting Maven Featured Poster

diafol:

A couple of questions if you don't mind...

  • If I am storing all of the profanity words in an array that is acting as an include file which is called before the data is submitted to the DB, how will anyone know how to find/view it in order to see how to by-pass the filter? I do not wish to hard code them directly into the page so the source can be easily viewed via right-click.
  • I was planning initially on doing this in PHP - Why do you suggest jQuery? (I am not very familiar at this point with JQ). What are the benefits of JQ in comparison to just using a PHP array to cycle through for the forbidden words, eliminate them from the form and show a message informing the User to correct the fields?
  • I do understand that some malcious people may atempt to by-pass the filter by misspelling curse words, but I am hoping to catch the most general, common and obvious words - I have a list of about 300 prohibited words to cycle through at this point.

Thanks much,
Matthew

mattyd 89 Posting Maven Featured Poster

Hello.

This is a multi-part question. I have researched each aspect of it before posting here, but I am posting this in case anyone may point out something I might have over-looked.

  • I am building a profanity filter to be used upon submission of a form - I assume, obviously, that this must be run before the actual data is submitted to the database. I am thinking this list of words (A seperate, include file of an array being called) should be located on the same page above the DB connection code. This I need to make sure about.

  • Also, upon submission, should there be profanity in the form fields I must notify the User; I have thought that if the profanity filter returns true for an offending word (From the array for any particular field) I would refresh the form page, the offending fields now empty, and display a jQuery message saying something to the effect of:"Please use appropriate content!". This part is confusing to me.

  • If the profanity filter catches a bad word in the form before submitting data to the DB, is it best to refresh/redirect the form/page like this? If so, where does this particular code go? Beneath the profanity filter code (Above the DB connection code) by using an AND OR to cycle through the array, for example?

I hope I am explaining this correctly and clearly.

Note: I have no code written for this yet to provide as an example for my question.

mattyd 89 Posting Maven Featured Poster

Fixed!

The error in the code was in line 62 - There was a comma required after tPerson.LastName.

Thank you so much for your help and I have learned something useful today.

Solved.

mattyd 89 Posting Maven Featured Poster

Pritaeas:

Okay, Thank you.

I have not tried it yet, but what I do not understand is, for example, (Line 61)

`

$tPerson_SQLselect .= "tPerson.Salutation, ";  

`

has a comma after tPerson.Salutation. What is the exact difference? Should they all not have the comma?

Upadate: I removed the comma following tPerson.eMail on line 65 - Saved - Ran - Am getting same errors in regards to Telephone and eMail as before.

I appreciate your help,
Matthew

mattyd 89 Posting Maven Featured Poster

When I add tPerson.Telephone and tPerson.eMail on lines 63,64 (And, I added Telephone and eMail rows to the table as well) I receive:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 110

(This warning is the one I referred to in my last post that I could not remember from earlier today)

I am not sure what to make of this now.

Reposting updated code:

`

<?php
/*

*   File:           nest_Demo_thrasher.php
*   By:         TMIT
*   Date:       2010-06-01
*
*   This script demonstrates in-elegant database thrashing
*       with a nested processing loop
*       
*
*=========================================================================
*/

{       //  Secure Connection Script
if ($dbSuccess) {

    {  //   Style declarations  
    echo '<h1>All Persons by Company</h1>';


    //      Company SQL
    $tCompany_SQLselect = "SELECT tCompany.ID AS companyID, ";      
    $tCompany_SQLselect .= "tCompany.preName, tCompany.Name, tCompany.RegType ";
    $tCompany_SQLselect .= "FROM tCompany ";

    $tCompany_SQLselect .= "ORDER BY tCompany.Name, tCompany.preName, tCompany.ID ";

    $tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect);

    {   //  while  more company records

            while ($rowCompany = mysql_fetch_array($tCompany_SQLselect_Query, MYSQL_ASSOC)) {

                $CompanyID = $rowCompany['companyID'];
                $CompanypreName = $rowCompany['preName'];
                $CompanyName = $rowCompany['Name'];
                $CompanyRegType = $rowCompany['RegType'];

                $CompanyFullName = trim($CompanypreName." ".$CompanyName." ".$CompanyRegType);
                echo '<h2 '.$indent50.'>'.$CompanyFullName.'</h2>';

                echo '<div '.$indent100.'>';
            echo "<table border='1'>";
                echo "<tr>";

                    echo "<td>#</td>";
                    echo "<td>Salutation</td>";
                    echo "<td>FirstName</td>";
                    echo "<td>LastName</td>";
                    echo "<td>Telephone</td>";
                    echo "<td>eMail</td>";

                echo "</tr>";  

                {   //  Person Table for companyID

                        {//     Person SQL
                            $tPerson_SQLselect = "SELECT  ";
                            $tPerson_SQLselect .= "tPerson.ID AS personID, ";   
                            $tPerson_SQLselect .= "tPerson.Salutation, ";   
                            $tPerson_SQLselect .= "tPerson.FirstName, tPerson.LastName ";

                            $tPerson_SQLselect .= "tPerson.Telephone, ";
                            $tPerson_SQLselect .= "tPerson.eMail, ";


                            $tPerson_SQLselect .= "FROM tPerson ";
                            $tPerson_SQLselect .= "WHERE tPerson.CompanyID = …
mattyd 89 Posting Maven Featured Poster

Pritaeas:

Yes, I noticed that earlier also, I believe. This should be happening around lines 62-63? I noticed earlier that both the Telephone and Email are missing directly after tPerson.LastName on line 62. Is that correct, what I am saying about this?

I tried adding both Telephone and Email after tPerson.LastName (as tPerson.Telephone and tPerson.eMail earlier but ran into some other problem that I cannot remember at the moment.)

Thank you for you assistance.

mattyd 89 Posting Maven Featured Poster

I am recieving a notice(s) multiple times when running a file:

Notice: Undefined index: Telephone in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 111
Notice: Undefined index: eMail in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 112

I have researched this and the ways to solve it. Most ways involve isset it seems, but none of my code in this example use Get.

Note: This code comes from a class I am taking on-line. I did not write the code. I have noticed during the class that the instructor has presented us files to download that contain obvious errors. When he runs this particular file he gets no notices like I am getting.

I also suspect that this has something directly to do with the DB - When I examine the structure of a particular table, it does not contain Telephone or Email rows to save data in, but all of the other necessary rows are there. Again, he created the DB/tables, not me. Is it possible that he forgot these rows and that is why I am getting these notices?

If the code runs and tries to store/retrieve data from rows that do not exist, that would be a major over-site, correct?

Here is his code:

`

<?php
/*

*   File:           nest_Demo_thrasher.php
*   By:         TMIT
*   Date:       2010-06-01
*
*   This script demonstrates in-elegant database thrashing
*       with a nested processing loop
*       
*
*=========================================================================
*/

{       //  Secure Connection Script
if ($dbSuccess) {

    {  //   Style declarations  
    echo '<h1>All Persons by Company</h1>';


    //      Company SQL …
mattyd 89 Posting Maven Featured Poster

This has been solved.

It seems like it was an issue with my code editor (BlueFish) or something.

When I removed the % in ($indx % 2) == 1), saved the file, and ran it I received the same error as noted in my original post.

I then re-added % to ($indx 2) == 1), saved it, ran it and it worked.

Not sure what happened there.

mattyd 89 Posting Maven Featured Poster

Hi,

The complete error message is: Parse error: syntax error, unexpected '2' (T_LNUMBER) in C:\xampp\htdocs\demo\nest_Demo_thrasher.php on line 115

The full code for the file in question:

<?php
/*

*   File:       nest_Demo.php
*   By:         TMIT
*   Date:       2010-06-01
*
*   This script demonstrates elegant nested rendering
*       using SQL rather than a language construct
*       
*
*=========================================================================
*/

{       //  Secure Connection Script
        include('../../htconfig/dbConfig.php'); 
        $dbSuccess = false;
        $dbConnected =    mysql_connect($db['hostname'],$db['username'],$db['password']);

        if ($dbConnected) {     
            $dbSelected = mysql_select_db($db['database'],$dbConnected);
            if ($dbSelected) {
                $dbSuccess = true;
            } else {
                echo "DB Selection FAILed";
            }
        } else {
                echo "MySQL Connection FAILed";
        }
        //  END Secure Connection Script
}

if ($dbSuccess) {

    {  //   Style declarations
            $trOdd = 'style = "background-color: #BFFFCF;"';
            $trEven = 'style = "background-color: #FCCDFF;"';

            $textFont = 'style = " font-family: arial, helvetica, sans-serif; "';
            $textRed = 'style = " font-family: arial, helvetica, sans-serif; color:maroon; "';

            $indent50 = 'style = " margin-left: 50; "';
            $indent100 = 'style = " margin-left: 100; "';

    //   END: Style declarations    
    }

    echo '<h1>All Persons by Company</h1>';

    {   //      SQL
    $tPerson_SQLselect = "SELECT  ";
    $tPerson_SQLselect .= "tPerson.ID AS personID, ";   
    $tPerson_SQLselect .= "tPerson.Salutation, ";   
    $tPerson_SQLselect .= "tPerson.FirstName, tPerson.LastName, ";  



    $tPerson_SQLselect .= "tCompany.ID AS companyID, ";     
    $tPerson_SQLselect .= "tCompany.preName, tCompany.Name, tCompany.RegType "; 
    $tPerson_SQLselect .= "FROM tPerson LEFT JOIN tCompany ";
    $tPerson_SQLselect .= "ON tPerson.CompanyID = tCompany.ID ";
    $tPerson_SQLselect .= "ORDER BY tCompany.Name, tCompany.preName, tCompany.ID, ";
    $tPerson_SQLselect .= "tPerson.LastName, tPerson.FirstName ";

    $tPerson_SQLselect_Query = mysql_query($tPerson_SQLselect);
    //      END:  SQL   
    }       
    $currentCompanyID = -1;
    $indx = 0;
    echo '<div '.$textFont.'>';

    while ($row = …
mattyd 89 Posting Maven Featured Poster

I am working with two seperate files which contain similar code - One throws a parse error for an identical line, the other does not. I do not understand why this would be.

The error on the file that will not run is: Parse error: syntax error, unexpected '2' (T_LNUMBER)

Here is a code snippet that works without the parse error:

if (($indx % 2) == 1) {$rowClass = $trOdd; } else { $rowClass = $trEven; } echo '<tr '.$rowClass.'>';

Here is a code snippet that does not work and has the parse error:

if (($indx % 2) == 1) {$rowClass = $trOdd; } else { $rowClass = $trEven; } echo '<tr '.$rowClass.'>';

Identical.

This error centers around the use of the 2, hence the (T_LNUMBER).

I see no difference in either code - I am simply doing ($indx % 2) == 1), the 2 being the problem for some reason.

Thank you in advance for any help!

mattyd 89 Posting Maven Featured Poster

diafol:

I have c + p your points above regarding security/etc into a Word file and will use it as a check-list when creating my build.

I will probably have some questions about some of the points in the future (Example: I really do not understand sessions at this point and how to implement and control them per individual registered User)

Thanks,
Matthew

mattyd 89 Posting Maven Featured Poster

Thank you all for your assistance. I spent the last couple of days thinking about how to proceed - I have not decided yet.

I am taking a PHP/MySQL class on-line so today I thought I should just keep doing that for awhile before comitting to any specific build principals.

I want to build my project correctly. Any security infiltrations will be a major problem (Although, after it goes live on 1.1.16, I plan on doing localized DB back-ups on a daily basis to a flash-drive so if I get hit I will be able to recover.) But, I don't wish that to happen. I really need to learn and understand the potential security holes before launch.

Thanks again,
Matthew

mattyd 89 Posting Maven Featured Poster

But one, small question about CI: Is this something where I will be installing software/files on my hosting server in order to make use of it?

Thanks.

mattyd 89 Posting Maven Featured Poster

iamthewee:

I am reading the documentation .pdf for CI and it already seems like it may be a very good option to put to use.

I may have to rebuild my site (The site is not live yet). It may prove better in the long run to do so.

mattyd 89 Posting Maven Featured Poster

I just downloaded the .PDF "CodeIgniter for Rapid PHP
Application Development" - It is a long read but I suppose it will answer my questions about how to use CodeIgniter if I go this route.

mattyd 89 Posting Maven Featured Poster

Thank you all for your responses and assistance. It is much appreciated.

I have downloaded CodeIgniter, but I will be honest, I have never used a framework before and really have no idea where to begin - Will this somehow modify my current code if used?

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

I am beginning what appears to be the daunting task of securing all of my code from injections, XSS, etc.

I have been reading about some of it and it is a bit overwhelming.

I just wanted to come here and ask for experts' advice on the main things I should be concerned about specifically.

There is so much on the Net about all of this I am not sure where to begin and I am sure I will miss something and leave at least one (if not multiple) vulnerabilities in my code, hence, allowing anyone access to my DB/tables.

Thank you in advance for any help.

Matthew

mattyd 89 Posting Maven Featured Poster

diafol:

Yes, that worked perfectly! Thank you so much for your help, I truly appreciate it. I was literally losing sleep over this issue last night.

This proves to me that I must learn PHP/MySQL better. I miss the tiny things that turn out to be huge problems.

I will remember this lesson for the future!

Kind regards,
Matthew D.

mattyd 89 Posting Maven Featured Poster

HTML page: (*Sorry for such long code snippet - It contains a huge list of countries)

<!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>

    <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="jquery, sliding, toggle, slideUp, slideDown, login, login form, register" />
    <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="js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <!-- Sliding effect -->
    <script src="js/slide.js" type="text/javascript"></script>


    <script>

    function checkforblack(document.getElementById('fname').value == "") {
    if () {
        alert ('Enter your first name');
        return false;
    }



    }


    </script>



    <!--Favicon-->
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>


<!--Country Dropdown-->

<!-- <msdropdown> -->
<link rel="stylesheet" type="text/css" href="css/msdropdown/dd.css" />
<script src="js/msdropdown/jquery.dd.min.js"></script>
<!-- </msdropdown> -->
<link rel="stylesheet" type="text/css" href="css/msdropdown/flags.css" />

</head>

<body>
<?php

define('DB_HOST', 'localhost');
define('DB_NAME', '****);
define('DB_USER','****');
define('DB_PASSWORD','****');

$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());


function NewUser()
{  
    $userName = $_POST['userName'];
    $email = $_POST['email'];
    $password =  $_POST['password'];
    $countries = $_POST['countries'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $query = "INSERT INTO Table3 (userName,email,password,countries,city,company) VALUES ('$userName','$email','$password','$countries', $city,$company)";
    $data = mysql_query ($query)or die(mysql_error());
    if($data)
    {
    echo "YOUR REGISTRATION IS COMPLETED...";
    }
}


function SignUp()
{
if(!empty($_POST['userName']))   //checking the 'user' name which is from …
mattyd 89 Posting Maven Featured Poster

I can provide the HTML, but what do mean specifically by the "SQL dump of the relevant tables"?

mattyd 89 Posting Maven Featured Poster

But, I am still not understanding the basics of why the Username and Password fields from the form are not saving to the DB; All other fields are being saved.

ETA: And, this used to all work before just fine. My hosting company apparently deleted the table I was using and I started over from scratch this morning. Errors galore!

Thank you in advance!

mattyd 89 Posting Maven Featured Poster

diafol,

I appreciate you insights and encouragement. No, it did not sound like a lecture but an informed individual sharing very important knowledge - That is one reason this site is so great!

I graduated from school for software engineering but I shall admit, I am still learning (And that is a good thing).

Kind regards,
Matthew

mattyd 89 Posting Maven Featured Poster

Thank you for your reply and honesty, diafol.

At this point this code is still in a build mode, hence, no MySQLi or many of the other aspects you have pointed out.

I really do not wish to scrap everything but I may be forced to do so.

I am working on it slowly and it is far from complete - I am glad you brought these issues to the forefront for me to ponder.

As to why I am collecting specific data in the form as you pointed out? That is classified. ;)

ETA: All data is validated for the form in another script.

Thanks again,
Matthew

mattyd 89 Posting Maven Featured Poster

Hello,

I posted a similar issue earlier - I fixed that issue that was throwing error messages and now my data from a form is being dumped to my table, well, most of it.

It is not recording the Username or Password fields and I have absolutely no idea why - There have been some changes made by another programmer and I am trying to unravel what they may have done. Originally, everything worked and was dumped into my table just fine.

Thank you for any help in advance!

<?php

define('DB_HOST', 'localhost');
define('DB_NAME', '******');
define('DB_USER','*******');
define('DB_PASSWORD','******');

$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());


function NewUser()
{

    $userName = $_POST['userName'];
    $email = $_POST['email'];
    $password =  $_POST['password'];
    $countries = $_POST ['countries'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $state = $_POST ['state'];//Added 11/3/2014

    $query = "INSERT INTO Table3 (userName,email,password,countries,city,company,state) VALUES    ('$userName','$email','$password', '$countries','$city','$company', '$state')";


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

function SignUp()
{
if(!empty($_POST['user']))   //checking the 'user' name which is from Sign-Up.html, is it empty or have some text
{
    $query = mysql_query("SELECT * FROM Table3 WHERE userName = '$_POST[user]' AND password = '$_POST[password]'") or die(mysql_error());

    if(!$row = mysql_fetch_array($query) or die(mysql_error()))
    {
        NewUser();
    }
    else
    {
        echo "SORRY...YOU ARE ALREADY REGISTERED USER...";
    }
}
}
if(isset($_POST['user']))
{
    SignUp();
}


?>
mattyd 89 Posting Maven Featured Poster

Thank you for your reply, Mike.

I am no longer getting that error message, thankfully, and most data from the registration form is being dumped into the table. Most. I will have to make a new thread regarding the fact that the username and password are not being saved from the form.

Everything was working fine until I allowed the programmer I hired to build a feature complete access to my database. Now, I am having to dig through new files and HER code and new variables she decided upon.

mattyd 89 Posting Maven Featured Poster

Hello:

Before I post code I will say that last year I hired a programmer to build one feature for my project. Today upon further inspection of the database/tables I am receiving errors that I have never received and I am at a loss as to their actual meaning.

I have researched this online and scoured the code but cannot figure it out (Another problem: This programmer apparently somehow dropped my table in my DB and I had to try to reconstruct it this morning - Very frustrating at this point)

I am at this point getting the following error which makes no sense to me: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Table 2 WHERE userName = 'gary bob' AND pass = 'uuuuuuuuuuuu'' at line 1".

Any pointer in the correct direction would be grealy appreciated - Thank you in advance!

`<?php

define('DB_HOST', 'localhost');
define('DB_NAME', '************');
define('DB_USER','************');
define('DB_PASSWORD','************');

$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());


function NewUser()
{

    $userName = $_POST['userName'];
    $email = $_POST['email'];
    $password =  $_POST['password'];
    $countries = $_POST ['countries'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $state = $_POST ['state'];//Added 11/3/2014

    $query = "INSERT INTO Table 2 (userName,email,password,countries,city,company,state) VALUES ('$userName','$email','$password', '$countries','$city','$company', '$state')";


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

function SignUp()
{
if(!empty($_POST['user']))   //checking the 'user' name which is …
mattyd 89 Posting Maven Featured Poster

<Bump>

I need help with this, please.

mattyd 89 Posting Maven Featured Poster

Hello.

I am attempting to implement a Captcha in my form using PHP.

This, at first, seemed pretty direct; Yet upon viewing the form, no Captcha is displayed, only code.

I noticed in the code there is an echo, Line 32 (Which I do not understand why that is even in there) and now the actual code is being displayed on the form, not the Captcha itself. Why would it be designed to do this?

I am very confused by this. Here is the code:

<?php 

/*
 * Define you SweetCaptcha credentials.
 * Don't have any? Sign up at http://sweetcaptcha.com and get them by email
 */

define('SWEETCAPTCHA_APP_ID', XXXXXX); // your application id (change me)
define('SWEETCAPTCHA_KEY', 'XXXXXXXXXXXXXXXXX
'); // your application key (change me)
define('SWEETCAPTCHA_SECRET', 'XXXXXXXXXXXXXXXX'); // your application secret (change me)
define('SWEETCAPTCHA_PUBLIC_URL', 'sweetcaptcha.php'); // public http url to this file


/////==== Do not change below here ===/////

/**
 * Handles remote negotiation with Sweetcaptcha.com.
 *
 * @version 1.1.0
 * @updated November 14, 2013
 */

$sweetcaptcha = new Sweetcaptcha(
  SWEETCAPTCHA_APP_ID, 
  SWEETCAPTCHA_KEY, 
  SWEETCAPTCHA_SECRET, 
  SWEETCAPTCHA_PUBLIC_URL
);

if (isset($_POST['ajax']) and $method = $_POST['ajax']) {
  echo $sweetcaptcha->$method(isset($_POST['params']) ? $_POST['params'] : array());
}

class Sweetcaptcha {

  private $appid;
  private $key;
  private $secret;
  private $path;

  const API_URL = 'sweetcaptcha.com';
  const API_PORT = 80;

  function __construct($appid, $key, $secret, $path) {
    $this->appid = $appid;
    $this->key = $key;
    $this->secret = $secret;
    $this->path = $path;
  }

  private function api($method, $params) {

    $basic = array(
      'method'      => $method,
      'appid'       => $this->appid,
      'key'         => $this->key,
      'path'        => $this->path,
      'user_ip'     => $_SERVER['REMOTE_ADDR'], …
mattyd 89 Posting Maven Featured Poster

My email vaildation is working correctly now.

But, I would like to alter the message color from black to red by styling it somehow.

I have attempted such things as:

{
        message = "Please, enter a valid email";
        message.style.color == 'red';

        writeMessage(message);  

        return false;

        }

The insertion being:

message.style.color == 'red';

The result is the entire script breaks.

Any ideas? Should I be using CSS for this?

Thank you,
Matthew

mattyd 89 Posting Maven Featured Poster

Hello.

I am finally figuring out some basic validation.

My main interest at this point is validating email.

The script I got online contains the following, but does not check for "com", etc:

if (email.indexOf("@") == -1 || email.indexOf(".") == -1)

This works but does not check for "com". It MUST check for "com". So, I added this:

|| email.indexOf +2 > text.length )

To come up with this:

if (email.indexOf("@") == -1 || email.indexOf(".") == -1 || email.indexOf +2 > text.length )

The results: After adding the "." and submitting, there is no error message indicating that the field is missing "com".

This is imperative that I fix this.

Please advise.

Thank you in advance!

Matthew

mattyd 89 Posting Maven Featured Poster

Thank you, GliderPilot.

mattyd 89 Posting Maven Featured Poster

I am about to begin protecting a yet to be launched site againt injection attacks.(And other possible attacks)

I am making use of a large database and must fortify this fully.

I am researching this but am here to pose the question: What should my main concerns be? Please be kind enough to list these.

I need to be aware of all vulnerabilities. I do not want my DB tampered with or dumped.

Please post links so I can study this more and prepare my defenses before anything goes live.

Note: I have a form which will allow user input - What do I need to be cautious of, specifically?

Any help or further points in the right direction will be greatly appreciated!

Thank you in advance.

Matthew

mattyd 89 Posting Maven Featured Poster

All fixed.

Thank you, JorgeM.

Matthew

mattyd 89 Posting Maven Featured Poster

Hello.

Having some trouble figuring out a CSS footer issue.

The footer should fill the page fully, not extend a horizontal scrollbar and importantly, not have a 3-5 pixel left gap.

I've tried all I know to fix this.

Here is the CSS for this:

footer
{
float: left;
min-width:100%;
padding:40px;
background-color:#c81818;   
margin:0px;
font-family:"Trebuchet MS",Helvetica, sans-serif;
color:#ffffff;
font-size:16px;
}

Please view the link below to see it live.

*Note: This is only a landing page for SEO-bots until the main site is built - It's not fancy or pretty

Click Here

Thank you in advance!
Matthew

mattyd 89 Posting Maven Featured Poster

I am working with a form validation script; I am testing it first and all seems to work fine except for the email validation.

This is a snippet of the script dealing with the email validation:

else if(! eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email ))
    {
        $_SESSION['reg']['email']="Please enter valid email address.";

For example, if a User enters the following in the email field, an error message is displayed, obviously: test1

If they enter test1@, an error is displayed.

If they enter test1@gmail.c an error is displayed.

But...

If they enter test1@gmail.co OR, for example, test1@gmail.cop it is validated as true - No error message displayed.

This makes absolutely no sense to me.

This is from that snippet, specifically handling User input of their email address

("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})

I am not familiar with the above at all and am not sure what to do to remedy this issue.

You can view and try this live if you wish: http://www.redlinedown.com/jQuery/registration/index.php

Thank you in advance for any help!

Matthew