broj1 356 Humble servant Featured Poster

Now, there might also be a problem in the password field definition in the table spec: password varchar(20) NOT NULL. As far as I remember the good old MD5 produces a hash of lenght that fits into CHAR(32). So password hashes stored in the users table could be truncated due to too small filed size and therefore can not match even if the user entered correct password.

However, more important fact here is that MD5 has been unfit for password hashing for years. It is completely unsecure and do not use it in any production site. There is much more suitable function password_hash (https://www.php.net/manual/en/function.password-hash.php) built into PHP. If you use it you must also make you password field bigger, maybe 255 characters to be ready for future.

Dani commented: Good catch! +34
broj1 356 Humble servant Featured Poster

If you intend to use quotes arround field and table names in Mysql you must use backticks, not single or double quotes. However they are not required if table and field names are not same as Mysql keywords/reserved words which is your case anyway. See the list of Mysql keywords here: https://dev.mysql.com/doc/refman/8.0/en/keywords.html

broj1 356 Humble servant Featured Poster

Not sure what exactly is the expected workflow but few notes anyway:

The PHP code in the beginning of the test.php should probably only execute after form submission or when the $_POST values are set so maybe perform a check or you might get errors/warnings:

if(isset($_POST['submit'])) {
    $user = $_POST['user'];
    echo 'User: ';
    echo $user. '<br><br>';
    ...
}

It is still not clear whether this code is necessary at all since your form redirects to the `welcome.php` page.

If you want to catch the output of your python script into the $output variable you have to set that as a parameter, something like

exec("python D:/text.py", $output);

Now you should have the output stored in the $output variable as an array. Maybe some other PHP external command function may be more appropriate (such as passthru - see https://secure.php.net/manual/en/function.passthru.php).

If you are on Linux make sure you have ownership and access permissions of the text.py script sorted right so it actually runs.

When inserting user supplied values into html code (whenever you use $_POST values in your html) you should sanitize them - use the htmlspecialchars function so possible harmful <script> or <iframe> tags get converted to &lt;script&gt; or &lt;iframe&gt; safe variants.

broj1 356 Humble servant Featured Poster

Quite many issues here:

The following code is not valid:

$valueToSearch = $_POST['requirementtype'  'build' ];

You can not have two strings as an array index. They should be separated in i.e two variables like so:

$searchRequirementtype = $_POST['requirementtype'];
$searchbuild = $_POST['build'];

These two values should be escaped before used in a query (google for SQL injection)

The SQL statement is not valid. There is no WHERE clause in it and no field you want to search in. Maybe something like:

"SELECT * FROM register WHERE `requirementtype` LIKE '%".$searchRequirementtype."%'";

On line 15 there is a stray <ul> tag without its end tag and any <li> tags.

The end </head> tag is also in a completely wrong place (at the end of the body).

The anchor <a> tag on line 23 can not have a method attribute. Was it supposed to be a <form> tag?

The <div> element on line 19 is in wrong place (you probably intended to put it in the <td> element).
Many elements, that are obsolete in HTML5, are used in your code (like <center>, cellspacing etc). Decent editor or IDE should display all the warnings.

You are missing the tr tags in the first table.

I recommend also that you use CSS for design and get rid of all presentation markup in your HTML. Since you use Bootstrap everything is already ready for you in the framework.

Maybe you clean up the code first, it will then be easier to help. This code here does …

broj1 356 Humble servant Featured Poster

In first version you are missing the other condition ($_SESSION['iiio'] != "pending"). In that case the div is shown by default.

It looks like you are using Bootstrap so you can use the show and hidden classes provided by Bootstrap. I am using ternary expression here since it is most convenient:

<div class="<?php echo $_SESSION['iiio'] == "pending" ? 'show' : 'hidden';?>"
<a href="https://www.paymentgateway.com">
<button align="right" id="completeReg" name="completeReg" class="btn btn-danger my-cart-btn my-cart-b" >Complete RegistrationComplete Registration</button>
</a>
</div>

If you are not using Bootstrap then create the two classes yourself:

.show {
    display: block;
}

.hidden {
    display: none;
}
Mr.M commented: Perfect +6
broj1 356 Humble servant Featured Poster

And do the same for your form fields since it seems that this is the cause of most of the above problems.

broj1 356 Humble servant Featured Poster

The ID that appear in the URL depends on the field names of the form that sends the data. A field in your form probably has a name attribute that equals to id and information entered into that field goes into the id variable in the URL. I would recommend that you name the fields in the form more descriptively like userid and courseid. Then you will know what ID is in the URL.

Also looking at your code you actually never use the variables from the URL in the queries. The session variable is used in your example in all queries. The above recommendation goes for the session variables, too. So $_SESSION['userid'] and $_SESSION['courseid'].

broj1 356 Humble servant Featured Poster

You should do it in a similar fashion. I presume the information about the gender is stored in a database for each user. When they login you read this information and redirect based on it. Something like:

if($row['gender']=='Couple MF')
{
     header('location:landingpage2MF.php');
}
else if($row['gender']=='Couple MM')
{
     header('location:landingpage2MM.php');
}
else if...
broj1 356 Humble servant Featured Poster

You can get the variables out of sight by using POST method in your form or call instead of GET which you are using in above example. If you use POST the variables won't be part of the URL instead they will be "hidden" in the HTTP header. Mind you the header can be inpsected by anyone with the access to the trafic so you should use TLS (https).

broj1 356 Humble servant Featured Poster

EDIT: I noticed after posting that the javascript functions are meant to be in a separate JS file. Disregard my 1. remark, sorry.

Had a quick look at the code and there are two obvious error:

  1. The Javascript functions are outside the <html></html> and outside the <body></body> pairs which is not OK. You should put them just before the closing </body> tag.
  2. On line 48 document.getElementById('tb2') an element with ID='tb2' does not exist

The correct code would be (nicely formated):

<!DOCTYPE html> <html lang="en"> <head> <title>Finance</title> <meta charset="UTF-8"> <meta name="finance" content="width=device-width, initial-scale=1.0"> <script src="insertrow.js"></script> <script src="calc.js"></script> <style>
table {
    padding-top: 15px;
}

button{
    margin-left: 15px;
    cursor: pointer;
}
</style> 
</head>
<body> 
<h1>Financial Keeps</h1> 

<button onclick="insertRow()">Add</button> 
<button onclick="deleteRow()">Delete</button> 
<button>Save</button> 
<p><b>Starting Amount: <input type="text" id="tb1" name="tb1" onkeyup="calc(this)"/></b></p> 
<p>To subtract an amount place a minus (-) sign infront of the dollar amount.</p> 

<table id="myTable"> 
<tr> <th>Bill Info</th> <th>Bill Amt</th> <th>Due Date</th> <th></th> </tr> 
<tr> 
<td><input type="text" id="text"/></td> 
<td><input type="number" id="number" onkeyup="calc(this)" /></td> 
<td><input type="text" id="text" /></td> 
<td><input type="checkbox" id="checkbox" /></td> 
</tr> 
</table> 

<p><b>Ending Amount: <span id="update">0</span></b></p> <input type="hidden" id="total" name="total" value="0" /> 
<script>
function insertRow() {
    var table = document.getElementById("myTable");
    var row = table.insertRow(table.rows.length)

    var cell1=row.insertCell(0);
    var t1=document.createElement("input");
        t1.id = "text";
        cell1.appendChild(t1);

    var cell2=row.insertCell(1);
    var x = document.createElement("input");
        x.setAttribute("type","number");
        cell2.appendChild(x);

    var cell3=row.insertCell(2);
    var y = document.createElement("input");
        y.setAttribute("type", "text");
        cell3.appendChild(y);

    var cell4=row.insertCell(3);
    var z = document.createElement("input");
        z.setAttribute("type", "checkbox");
        cell4.appendChild(z);;
}

function deleteRow() {
    document.getElementById("myTable").deleteRow(2);
}   

var x = 0;
var y = 0;
var z = 0;
function calc(obj) {
    var e …
broj1 356 Humble servant Featured Poster

You can also check how the query gets constructed, using similar technique as described above by cereal. Just add this between line 2 and 3:

die($query);

This will print out the query on the screen and stop the script. Now you can inspect the query whether it has all the correct values and no syntax errors. Also you can copy the query and test it in your database directly (e.g. in PhpMyAdmin if you are using it) and see what is returned.

broj1 356 Humble servant Featured Poster

If you have a fixed number of variables (known in advance and equal to the lenght of the $row) you could use the list function. Something like:

list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m) = $row;

But be aware that using an array instead of lots of variables is often more practical and handy.

And please note the mysql_* functions are deprecated (use PDO or mysqli).

diafol commented: Another mysql caveman! +15
broj1 356 Humble servant Featured Poster

You can not subtract two strings representing dates on line 4 and expect to get a difference. Besides the variables on line 4 have not been declared anywhere (but I guess you just misstyped them).

The best thing to do is to use the DateTime and the DateInterval PHP classes. There is a nice example at the later link which I adapted for your case:

$start_time = $row['start'];

$datetime1 = new DateTime($start_time);
$datetime2 = new DateTime('now');
$interval = $datetime1->diff($datetime2);
$duration = $interval->format("%H hours %I minutes %S seconds");

I am assuming that $row['start']contains a valid date string (you should add code to check this) and you are comparing it with the current time (you can addapt the code for other cases). If you want to have hours in 4 digits, use the str_pad function.

broj1 356 Humble servant Featured Poster

Looking at your code the new_entries table is in another database (newentries). Is that what you really wanted to do? You are duplicating rows (althoug in another database) so maybe you first review your DB design.
If that is OK, make sure connection to the newentries database is OK and the query is also OK. You can check the error log. In WAMP typical locations might be C:\wamp\logs or C:\wamp\php\logs. You might find some clues there. You can also echo the query out by putting the following simple debug code after line 78:

die($sql);

This will echo your query on screen and stop the script. You can copy the query and paste it into phpmyadmin to test it (make sure you select the newentries database first).
The associative indices of the $_POST array elements should be enclosed in quotes to avoid possible errors. So $_POST[ISBN] should really be $_POST['ISBN']. This might require that you escape some quotes. Also array elements within a double stringed qoute need to be enclosed curly braces to be parsed OK. So the code might look like this:

$sql="INSERT INTO newentries.new_entries(ISBN,Book_title,Author,yr_of_publication,Edition,Module,Department) VALUES('{$_POST[\"ISBN\"]}', '{$_POST[\"Book_title\"]}', '{$_POST[\"Author\"]}', '{$_POST[\"yr_of_publication\"]}', '{$_POST[\"Edition\"]}', '{$_POST[\"Module\"]}', '{$_POST[\"Department\"]}')";

And a warning: using POST variables directly in a query is a bad practice. You should cleanse/filter/sanitize/ those variables first so you do not get some nasty data in.

broj1 356 Humble servant Featured Poster

Quite many issues here, some big, some smaller. I'll try to comment on some without any particular order of importance.

  1. On line 9 you try to concatenate some unknown constant. It should be either a variable (i.e. $error, but defined somewhere) or mysqli's error function mysqli_connect_error().
  2. I strongly advise against using HTML tables for positioning elements. This is not strictly an error but it is a bad design practice. Google for semantic html. In your case a table within table calls for problems, since tr tags are already messed up
  3. There is no need to disconnect from DB and then reconnect on line 15
  4. The real problem is that the code for inserting into DB should trigger only on submitting the form probably on the for.php page.
  5. The $_POST['option1'], $_POST['option2']... elements do not exist since they have not been defined anywhere in the form. You should probably use $_POST['radio1_1'] since this is the name of your radio button. Probably you should have more radio buttons for each question.
broj1 356 Humble servant Featured Poster

I tried your code and the table gets generated OK. I get this:

Age Beg Bal Interest    Deposits    Ending Bal
45.00   2000.00 324.65  1200.00 3524.65
46.00   3524.65 521.09  1200.00 5245.75
47.00   5245.75 742.58  1200.00 7188.33
48.00   7188.33 992.31  1200.00 9380.63
49.00   9380.63 1273.87 1200.00 11854.50
50.00   11854.50    1591.33 1300.00 14745.83
51.00   14745.83    1949.42 1200.00 17895.25
52.00   17895.25    2352.98 1200.00 21448.23
53.00   21448.23    2807.99 1200.00 25456.22
54.00   25456.22    3321.00 1200.00 29977.22
55.00   29977.22    3899.41 1200.00 35076.63
56.00   35076.63    4551.56 1300.00 40928.19
57.00   40928.19    5287.01 1200.00 47415.20
58.00   47415.20    6116.02 1200.00 54731.22
59.00   54731.22    7050.72 1200.00 62981.95
60.00   62981.95    8104.58 1200.00 72286.52
61.00   72286.52    9292.77 1200.00 82779.30
62.00   82779.30    10632.44    1300.00 94711.74
63.00   94711.74    12143.04    1200.00 108054.78
64.00   108054.78   13846.03    1200.00 123100.81
65.00   123100.81   15766.11    1200.00 140066.92

What browser and what environment are you using? Is Javascript enabled? Do you get any errors in the console? Have you looked at the generated HTML source?

broj1 356 Humble servant Featured Poster

Use PHPExcel to create Excel file from the data you read from the database. Dynamic headers are just headers that contain text and formulae in them (the header changes if the information in the respective column changes). You have to build those formulas yourself.

broj1 356 Humble servant Featured Poster

If this is a guide how to do something it has serious issues:

  • POST variables are not being sanitized so arbitrary code can be injected
  • An old and deprecated mysql extension is used

So sanitize (check, validate, cast, replace, blacklist, whitelist...) the post data and switch to the PDO extension for accessing the DB.

broj1 356 Humble servant Featured Poster

Sure. Often a good approach is to break complex tasks into simpler problems and solve each one separately. Anyway, when you bump into problems come here for help :-)

broj1 356 Humble servant Featured Poster

This code already uses jquery (so do not forget to include it). This is the simplest possible version. In reality it will be more complex. But that depends on what you want ot achieve. Who do you want to send the email to? What information should be in the email. What feedback would you like when the email was successfuly sent? What feedback you want on unsuccessful sending attempt? For all these situations you have to provide some solutions.

But it is better learning in small steps if you are new to the concept. So try to run the above code in your environment and see what questions pop up. Also try to figure out what else you would need and see how to make it happen.

broj1 356 Humble servant Featured Poster

Yes, this is where Ajax comes in. But I do not find those two triggers ("Emailed Customer" and "Email Mitch") in your code snippets. Where are they?

But the simplest basic example would be:

HTML:

<input type="checkbox" name="email-trigger" id="email-trigger">
<label for="email-trigger" class="custom-unchecked">Send email</label>

Javascript (Ajax part) - put it in the HTML file just before the closing body tag:

...
<script>
$("#email-trigger").on("click", function() { // on click event on the element with id=email-trigger
    $.post('send-email.php'); // use post method to call (request) the send-email.php script
});
</script>
</body>

The send-email.php script does the usual email creation and sending. This is very simplified example but it shows the concept. In more advanced scenario you can add data that can be part of the request (maybe the email or ID if the user) and return some data from the emailing script (like mail sent successfuly or possible errors). Returned data can be inserted into HTML or maybe logged.

broj1 356 Humble servant Featured Poster

I tested your code and checkboxes work OK. So if you check the Equipment Required? checkbox , both Ordered? and Config? checkboxes get checked. If you check either of the later two, the parent gets appropriately checked. The opposite direction also works. So this part works OK.

But you do not need Ajax for this. You need Ajax for sending an email without reloading the page. From your snippet I do not know which action should trigger the emailing. So please explain how would you like the email sending work (what triggers the email sending script, what data from the page would you like to include in the mail, what response would you like to have after sending the mail...).

broj1 356 Humble servant Featured Poster

Ajax is actually an approach or a concept where you use existing technologies. The main advantage is that you do not reload the page when you do a new HTTP request. Typical example is a shopping cart. When you add a product to it you do not want to reload the whole page just to update the cart information. In your particular example you would process a click (request a php script that takes care of sending an email) while user keeps on browsing on your page without a disturbing reload.

This is what the acronym stands for:

A - Asynchronous means that another (asynchronous) HTTP request is triggered from the browser without disrupting the user experience
J - Javascript is used to fire and handle the request
A - is just 'and'
X - XML is used as a data transfer format but this is not strictly true since you can also transfer HTML, JSON or plaintext

Much better explanation can be found on Wikipedia.

So you do not need to install any new software, everything is already there. All you need is a decent browser (basically all browsers have been supporting ajax for last ten or so years), javascript and your code. It also does not matter if your environment is Linux or Windows or anything else.

Since HTTP request in Ajax context is implemented slightly differently in each browser (don't ask me why) you have two options: either 1. code in plain …

broj1 356 Humble servant Featured Poster

Is it possible to do a nested checkbox

It is, but you will have to code. Use Javascript or even better jQuery to listen to the click event and to check related checkboxes upon clicking the main one. It is easier if you put related checkboxes in a container (such as div), to simplify finding elements. The question is what to do when the checkbox is cleared. Do you clear all the related checkboxes too? What if some of them were clicked before. In that case it would be a good idea to save the state of checkboxes first.

Is it possible to have a checkbox trigger an email

Sure it is. I would use Ajax for that (again jQuery or something similar). Clicking a checkbox would trigger another PHP script that would do the mailing (without reloading the original page, so user is not disrupted). But there might also be a problem. Many users (include myself) click on checkboxes without any intention of doing something (it is so tempting to click on checkbox and then click again on it to return it ot the original state). You have to prevent a posibility of too many emails being sent just because of hyperactive users. You could either implement an additional check ("Do you really want to send an email") or implement a timer so emails get sent only if there is a big enough time difference.

broj1 356 Humble servant Featured Poster

Displaying images in a grid is probably better since your page will be displayed nicely on mobile devices - provided that your grid is set-up properly. You can use a proven framework for that such as Bootstrap.

If you want to display images in pages use pagination - google for tutorials using the search term 'php pagination tutorial' or 'php pagination example' or maybe just look at this one.

broj1 356 Humble servant Featured Poster

If you want to prevent unauthorised users from displaying the iamges you can encrypt them using mcrypt_encrypt. But be aware that you have to deal with key management to be able to decrypt later. By that I mean generating secure keys, securely storing the keys not to expose, corrupt or loose them etc). Maybe not that important since you still have images in the database. And BTW, does admin not have acess to the database (or put it differently can you prevent him to access it without you knowing it)?

broj1 356 Humble servant Featured Poster

I can't test the code since I am on Linux and using Firefox and Chrome. However my recommendation is that you use jquery functions in your javascript code since jquery is meant to abstract browser differences. Looking at your code you did include jquery library but are not using it. Also you could consider including latest version of jquery (either 2.2 or 1.12 if you need 1.x backward compatibility).

Other good tool for checking compatibility with any browser is Modernizr. You can use it to test whether a browser supports a feature you want to implement.

broj1 356 Humble servant Featured Poster

PHPExcel site is here, documentation is here. Great library, I have used it many times.

broj1 356 Humble servant Featured Poster

Try :

echo $user_data[0]['fullname'];

since fetchAll returns a set of all the rows (only one in your case).

broj1 356 Humble servant Featured Poster

You could use jquery ajax post method. The data for the post would be all the parameters, that are needed for the public function. The page won't refresh but you will still be able to carry out the insertion into the database. But you need a javascript event to triger the jquery call. It can be page load / ready, click change or similar, depending on what you want to do. This is a made uo example for teh click event (i.e. clicking a submit button in the form).

<script>
$("trigger-element").on("click", function() {
    $.post(
        "data.php",
        { 
            projectid: "<?php echo $projectid;?>",
            projectnaam: "<?php echo $projectnaam;?>",
            startdatum: "<?php echo $startdatum;?>",
            ...
        }
    );
});
</script>

On the data.php page you will catch the parameters in the $_POST array.

<?php
$projectid = $_POST['projectid'];
$projectnaam = $_POST['projectnaam'];
...

// now when you have parameters call the create() function
$myObject->create($projectid,$projectnaam,$startdatum,$einddatum,$omschrijving);

You might also want to do some checking of input data before you use it in your query. Hopefuly the example above does not contain typos since I did not test it.

broj1 356 Humble servant Featured Poster

Or use more jquery-like approach, where you catch onclick event in jquery:

<button type="button" class="btn-login" id="btn-login">Login</button>
...

<script>
$("#btn-login").on("click", function() {
    toggle_visibility('foo'); 
    toggle_visibility('sidebar'); 
    toggle_visibility('tiles'); toggle_visibility('wsf')
});
</script>
</body>
broj1 356 Humble servant Featured Poster

Please show code you have so far. It is hard to guess without seeing it.

In general in jquery you use show and hide methods. The elements have to have classes or ids so you can target them with jquery.

What functionalities would you like ajax to carry out? As said, hard to help without code.

broj1 356 Humble servant Featured Poster

Are you using jquery or pure javascript?

broj1 356 Humble servant Featured Poster

http://api.jquery.com/jquery.ajax/

You might have to do a bit of learning if you are not familiar with Ajax.

broj1 356 Humble servant Featured Poster

The correct query would be:

$sql = "INSERT INTO Guests (firstname, lastname) VALUES ('Sam', 'Smith')";

The code will get created automatically. When you want to create the input element using the last ID, first read the last ID from the database:

$sql = "SELECT MAX(code) AS last_id FROM guests";
if($result = mysqli_query($link, $sql)) {
    $row = mysqli_fetch_assoc($result);
    $last_id = $row['last_id']);
}

and then as you did it above:

<input name="code" type="text" value="COD<?php echo $last_id;?>">

Mysql MAX() function will always return the last ID since it is the highest number if you use autoincrement.

broj1 356 Humble servant Featured Poster

Not sure if I understood ypur question but I'll have a go at it.
The mysqli_insert_id() function returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute (sentence copied from the PHP manual). Now, in your insert query the ID is not treated as an autoincrement type, or if it is, you should not supply value for it - it will be created automatically by the DB server. Autoincrement fields can only be of an integer type so you will have to append string characters in the PHP code (as in your example above).

If the answer is not what you wanted please elaborate what you want to do and what errors do you get.

broj1 356 Humble servant Featured Poster

Assuming that you use the POST method the users name should be in the $_POST array. Read it from there. Details depend on whether you have insertion script and the form in the same script or not. Maybe you post your code.

broj1 356 Humble servant Featured Poster

You use one of jquery ajax methods, i.e. $.ajax(). HTTP method should be POST since you are updating data (see some in-deepth explanation here and some simpler explanation here). You supply the data to be inserted in JSON format.

The $.ajax method is usually called with a click event (e.g. user clicks on a button) and can be coded something like:

$.ajax({
    method: "POST",
    url: "insertscript.php",
    data: { field1: "Value 1", field2: "Value 2" }
})
    .done(function(msg) {
         alert("Data Saved: " + msg);
    });

The url points to the script that will actually do an insert. The data object contains the data for the fields that have to be updated. You will read it from the $_POST global variable in the script that updates the database (it is very important that you sanitize/escape this data before sticking it into the database). The done function will get called once ajax call is finished with success. Instead off alert you can stick some HTML into a div that is meant to display messages or something similar.

The insertscript.php PHP script could be someting like:

<?php
$field1 = some_escape_function($_POST['field1']);
$field2 = some_escape_function($_POST['field2']);
// connect to the database

...
// insert into database
$query = "INSERT INTO mytable (field1, field1) VALUES (' $field1', ' $field2')";
$success = myDatabaseFunctionFor Inserting($query);

// return appropriate message depending on success
// (this message will be caught by $.ajax function in the msg variable above)
if($success) {
    echo "Inserted successfully …
broj1 356 Humble servant Featured Poster

Cool. Do research, try some examples and if you run into trouble, post here (include your code snippets, describe where you got stuck). We'll be glad to help. Happy coding.

broj1 356 Humble servant Featured Poster

Sory I ment to put the die statement after line 60, that is before line 63, so the insert query gets displayed. This way you test the insert query is constructed correctly.

It is actually hard o test your case since there are some include statements. But if nothing else helps I will do this. In that case post complete script and at least the form_functions.inc.php script

broj1 356 Humble servant Featured Poster

Test the insert statement. Put this simple debug code just before line 60:

die($q);

This will echo the insert query on screen and stop the script. Now inspect the query whether it is OK and copy and test it in phpmyadmin (or whatever you use).

Also, you check if user exists:

$q = "SELECT email, username FROM users WHERE email='$e' OR username='$u'";

and the if it does not exist if ($rows === 0), you do an insert, which is OK. But your oter condition if($rows === 2) is strange since if user is registered, you should find one row only, shouldn't you?

broj1 356 Humble servant Featured Poster

In each script that uses session variables you have to have the session_start function on the very top of the script. It is important that no HTML or other output is sent before this function. Make sure there is not even a space before the first opening <?php tag.

broj1 356 Humble servant Featured Poster

Nowhere you check if password and username have been entered which is not a good practice and might be a reason for your error. You should do it this way:

if(!isset($_SESSION['auth_user']) && isset($_POST['cedula']) && isset($_POST['clave'])) {
    loginuser();
}

Also use curly brackets even if you have only one statement, to avoid coding errors.

$result = mysql_query("SELECT * FROM personas WHERE cedula='".$_SESSION["cedula"]."' ");

Using raw uncleansed form input is extremely dangerous (sql injection). Do filtering, cleansig, whitelisting, casting etc. before using form data in queries.

In your function you use ADO and in your code you use deprecated mysql extension. Was this your intention or just blind copying of example code? It might be another possible cause for errors. Also avoid mysql extension completely since it is outdated and deprecated.

$recordSet = &$conn->Execute("$sqlstmt");

Referencing object is also deprecated.

Using functions to render HTML is not a good practice (in my personal view). I prefer functions to process something and return result or FALSE. This way HTML is not hard coded and I can easily change it.

broj1 356 Humble servant Featured Poster

In my knowledge the cal_days_in_month function already takes into account leap years. I think the error is in line 10:

$Start_Date="1/".$month."/".$year."";

To make string representation correct it should be in a format that represents a unique date (i.e. American month, day and year - mm "/" dd "/" y):

$Start_Date=$month."/"."1/".$year."";
// or in more readable form
$Start_Date = "$month/1/$year";

And this is my version of the calculate function:

function calculate($month, $year) {
    $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
    $workDays = 0;
    for($d = 1; $d <= $daysInMonth; $d++) {
        $dateString = "$month/$d/$year";
        $currentDayTS = strtotime($dateString);
        $day = date("D", $currentDayTS); // Sun - Sat
        if($day != "Sun" && $day != "Sat") {
            $workDays++;
        }
    }
    return $workDays;
}
broj1 356 Humble servant Featured Poster

As I remember immediately after installation you should be able to access http://localhost and get the default XAMPP page (or WAMP if you use it), but not https://localhost. Regarding to info.php I don't think it exists by default (but I might be wrong). You have to create it and put phpinfo() function in it, as far as I know.

I also searched for some info on ERR_CONNECTION_RESET. What I found was a bunch of different articles most of them relating to some network configuration issues, like this one: https://www.youtube.com/watch?v=9orMZyky-UI. I do not know how this might help you.

broj1 356 Humble servant Featured Poster

http://www.html-form-guide.com/php-form/php-form-checkbox.html

and thousands of other resultls using duckduckgo search for php checkbox example (you can also try google)

broj1 356 Humble servant Featured Poster

Does your server certificate CN (common name) and the ServerName directive in the virtual host configuration match? But I don't think this would prevent you to at least load the homepage. Can you also try with http instead of https?

Also, do you have Skype running at ht e same time? It is known that Skype takes over port 80 and I believe port 443 also. In that case you change ports either in Skype (recommended, if you ask me) or in Apache virtual host config.

broj1 356 Humble servant Featured Poster

The log does not show any errors only few notices. How do you access your local server (waht is the local URL)? Do you have entries in the hosts file for your virtual hosts?

broj1 356 Humble servant Featured Poster

Have you checked Apache log files? If you use xampp they should be in C:\xampp\apache\logs.

broj1 356 Humble servant Featured Poster

Do not forget security if you want to be a really good web developer. Familiarize yourself with OWASP top 10 threats and guidelines how to handle them.

Regarding graphics skills learn vector graphics and software like Inkscape. It often helps when bitmap graphics does not suffice.