broj1 356 Humble servant Featured Poster

I have added some new code to the toggleDiv() javascript function. This code hides dispplay of all divs on the page - either diplayed or hidden(see my previous post).

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"> </script>
<script type="text/javascript" >
function toggleDiv(divId) {

    // ***** NEW CODE *****

    // number of forms (you can set that programatically)
    var numberOfForms = 2;

    // variable for storing each div's ID
    var fmDivId = '';

    // first loop through al forms and hide their divs
    for(var i= 1; i <= numberOfForms; i++) {

        // current form's ID
        // (suppose your divs have IDs like form1, form2...)
        fmDivId = 'form' + i.toString();

        // set display to none
        document.getElementById(frmDivId).style.display == 'none';
    }

    // ***** END OF NEW CODE *****

    var el = document.getElementById(divId);

    if(el.style.display == 'none') {

        el.style.display = 'block';
    } else {

        el.style.display = 'none';
    }
}
</script>

</head>

<body>
<a href="#" onclick="toggleDiv('form1');">Form 1</a>
<a href="#" onclick="toggleDiv('form2');">Form 2</a>

<div id="form1" style="display:none;">
<form >
Name<input type="text" />
</form>
</div>
<div id="form2" style="display:none;">
<form>
Surname<input type="text" />
</form>
</div>
<br />
</body>
</html>
broj1 356 Humble servant Featured Poster

If you used the javascript to display a form you can enhance the function to first hide display of all forms and then open the selected one.

function toggleDiv(divId) {

    // number of forms (you can set that programatically)
    var numberOfForms = 7;

    // variable for storing each div's ID
    var fmDivId = '';

    // first loop through al forms and hide their divs
    for(var i= 1; i <= numberOfForms; i++) {

        // current form's ID
        // (suppose your divs have IDs like form1, form2...)
        fmDivId = 'form' + i.toString();

        // set display to none
        document.getElementById(frmDivId).style.display == 'none';
    }

    // then display the selected form as ususally

    var el = document.getElementById(divId);

    if(el.style.display == 'none') {

        el.style.display = 'block';

    } else {

        el.style.display = 'none';
    }
}
broj1 356 Humble servant Featured Poster

Which solution did you implement? Was it the javascript one or the one with forms as variables?

broj1 356 Humble servant Featured Poster

It is a bit difficult to give you an exact answer but I think your Quiz class should have all the attributes and methods to handle the quiz, such as a method to display a question (which you already have), an attribute (an array) with correct answers for all questions, a method to check the correctness of each answer, a method to display result for each question, a method to calculate overall score, a method to store data in database (whichever data you wish to store) etc. The getQuestion() method could be split into two: one to connet to the database and the other to select and display questions to achieve esier maintainability.

broj1 356 Humble servant Featured Poster

I am not sure whether I understand your question but let me try.

Enclose each of your forms with a div that has a CSS display property set to none like this:

<div id="form1" style="display:none;">
<form>
...
...
</form>
</div>
<div id="form2" style="display:none;">
<form>
...
...
</form>
</div>

Then write a javascript function that toggles the display of a div like this

function toggleDiv(divId) {

    var el = document.getElementById(divId);

    if(el.style.display == 'none') {

        el.style.display = 'block';
    } else {

        el.style.display = 'none';
    }
}

Assign this javascript function to onclick event of each link like:

<a href="#" onclick="toggleDiv('form1');">Form 1</a>
<a href="#" onclick="toggleDiv('form2');">Form 2</a>
...
broj1 356 Humble servant Featured Poster

Your input should be between the <form></form> tags and the form should have an action attribute set to the same page.

broj1 356 Humble servant Featured Poster

You are missing a curly bracket at the end of line 9 jn the above code.

$distance = $cities[$_POST['destination']]};
broj1 356 Humble servant Featured Poster

Obviously $_POST array does not contain a 'txt_xml_users' key which suggests that this data has not been supplied by the form. You have to implement some means of checking for valid input such as:

if(!isset($_POST['txt_xml_users'] or empty($_POST['txt_xml_users'])) {

   // warn the user to enter valid data
} else {

   // do all your normal processing here
}
broj1 356 Humble servant Featured Poster

Man, you must be in love with the if clause. It seems that you have one curly bracket missing at the end between lines 168 and 179. Your code is very complex and hard to follow but my IDE shows that what is marked as:

}//end foreach

is really end of if block starting on line 45. If I insert a curly bracket at the end, all the brackets are in pairs but I do not know whether the code is what you intended.

broj1 356 Humble servant Featured Poster

I have made some changes to your code and it works perfectly well in my browser. Changes are in comments.

Main thing is that you should use session_unset() php function to unset the session (I wrongly advised you to use unset($_SESSION) which is not recommended, sorry). See http://php.net/manual/en/function.session-unset.php and also read the comments. The rest is in code which is largely simplified, so it needs to be worked upon before the production! Hope it helps.

index.php (login page)

<?php

    // start session
    session_start();

    // unset any session data until user submits valid username and password
    // this is correct way not unset($_SESSION), sorry my mistake
    // see http://www.php.net/manual/en/function.session-unset.php
    session_unset();
    session_destroy();

?>

<h3>Login</h3>
<form method="post" action="proseslogin.php">

    <div>
    <labelfor="username">Username</label>
    <br />
    <input type="text" name="username" />
    </div>

    <div>
    <labelfor="password">Password</label>
    <br />
    <input type="password" name="password" />
    </div>

    <div><input type="submit" name="submit" value="submit" /></div>

</form>

proseslogin.php

<?php

// start session
session_start();

    $username = $_REQUEST['username'];
    $password = $_REQUEST['password'];

    // *** set login to false not to '' to be consistent with the return value
    // *** of the function periksa()
    $login = isset($_POST['login']) ? $_POST['login'] : false;

    // DEBUG CODE 1
    // uncomment last two lines and you should see the values that were
    // sent by the login form
    //
    // print_r($_REQUEST);
    // die();

//function
function periksa ($username, $password){

    if (($username=="guest") and ($password=="guest")){

        return true;

        } else {

            return false;
        }
    }

// cek
if (periksa($username, $password)) {

    $login=true;

} else {

    echo "Wrong user ID or password!";

    header("Location: index.php"); …
broj1 356 Humble servant Featured Poster

Make sure you do not send any character (not even a space) before header directive on line 9 otherwise the header will not be sent. You can test that if you put the code

if(headers_sent()) {
    echo 'Headers have already been sent';
}

after line 10 on admin.php. If you see this notice than you have sent some contents before sending the headers.

If you post complete code for your pages I can test them in my environment but not before tomorrow since I have to finish a project for the customer tonight. Meanwhile you can put the following code:

print_r($_SESSION);

or

die($_SESSION);

in various places to check wheter the contents of the session is what it should be. Appropriate places would be lines 8 and 12 in admin.php, line 8 in logout.php etc.

broj1 356 Humble servant Featured Poster

On the proseslogin.php page, line 39 shoud make more sense if it was:

$_SESSION['username'] = $username;

so it works for any user.

On the admin.php page do unset first and then redirect (swap lines 9 and 10).

On the admin.php page the condition statement is wrong. It should be:

if(!isset($_SESSION['username']) or $_SESSION['username'] !='guest')

But I am confused here since I assume that guest should not be allowed to access admin page!? So what is really the condition you want to check?

broj1 356 Humble servant Featured Poster

On your loging page you should start with

// start session
session_start();

// unset any session data until user submits valid username and password
unset($_SESSION);

Then when user enters a valid username (i.e johnybegoode) and password set session variables you need, such as

$_SESSION['username'] = 'johnybegoode';

Then on other pages for that user first check for valid username using the code from previous post

<?php 
session_start(); 

// say that user johnybegoode has successfuly logged in and $_SESSION['username'] was set
// to johnybegoode

if(!isset($_SESSION['username'] or $_SESSION['username'] !='johnybegoode')){
// re-direct ke index.php  

header("location:index.php");  
}  
?>

Then provide a logout link which points to the login page. When user clicks on it (logs out) the session is unset on the login page first.

Option 2: Your logout link can point to some other page (logout.php) where you can thank the user, unset session, do other cleanup, log the event etc and automaticaly redirect to login page.

Note: you can not unset session with javascript onclick directly, you have to use ajax and implement a javascript function that calls a php script that unsets the session but that is a more complex topic.

Even more important note: in this example there was nothing said about security. Make sure you do all the security exercises when dealing with input and session. See previous posts in this thread and other threads here and arround.

broj1 356 Humble servant Featured Poster

Sorry, my typing error. It should be:

if(!isset($_SESSION['username']) and $_SESSION['username'] !='guest'){

I usualy check code before I post but haven't done so this time.

broj1 356 Humble servant Featured Poster

One possible reason could be that you are only checking for the existence of username in the session but not the value of it. Try it this way:

<?php 
session_start(); 

// say that user johnybegoode has successfuly logged in and $_SESSION['username'] was set
// to johnybegoode

if(!isset($_SESSION['username'] or $_SESSION['username'] !='johnybegoode')){
// re-direct ke index.php  

header("location:index.php");  
}  
?>

Another reason could be that you do not unset $_SESSION upon unsuccessful login or upon logout.

broj1 356 Humble servant Featured Poster

PHP6 and MySql Bible, Wiley, was very informative for me (note PHP6 is not out yet, but the book it is OK for PHP5 too).

http://www.amazon.com/PHP6-MySQL-Bible-Steve-Suehring/dp/0470384506

broj1 356 Humble servant Featured Poster

\n is not a html tag. It does insert a new line in the source (view page source and you will see it). To have a new line in html page you need to use either <br /> or wrap each line in <p></p> or <div></div> pair like

echo "<div>value of \$count is ::> $count </div>" ;

You can change the spacing between lines with css.

The other option is to use nl2br() function. See http://php.net/manual/en/function.nl2br.php.

broj1 356 Humble servant Featured Poster

You should set atribute name of the checkbox to

name='item[]'

so that you create a checkbox group. Upon submitting the form you will get all checked values in an array stored in $_SESSION. The array can be empty if none of the checkboxes were checked, so use empty() to check for values first. You loop through array and handle the values:

if(!empty($_SESSION['item'])) {

    echo "You clicked: ";
 
    foreach($_SESSION['item'] as $oneCheckboxValue) {

        // do something with the checkbox value, like echo
        echo oneCheckboxValue . ' ';
    }

} else {

    echo 'None of the checkboxes has been clicked.';

}

Another thing not related to this question is that id atributes should be unique for each element. So make sure that id atributes change for each checkbox, maybe like in the following example:

$i = 1;

// your loop here

    echo "<input type='checkbox' name='item[]' id='item$i++' value=\"{$row6['id']}\" />;

// end of loop

That is how you wont have any troubles when using javascript in future. And also input elements do not have closing tag so they should be terminated by / (see above).

broj1 356 Humble servant Featured Poster

The function session_is_registered() is deprecated (as the notice says) which means that it might be dropped in future and you are discouraged to use it. See http://php.net/manual/en/function.session-is-registered.php. Check the session variable instead, which has the same effect:

<?php 

session_start(); 

if(!isset($_SESSION['username']){
 
    //re-direct ke index.php
    header("location:index.php");
}

?>

.

broj1 356 Humble servant Featured Poster

The third block of code is OK, that is how you do it. Of course you can also have functions in a separate file like in your second block example in the fix_name.php file. Only the line 4 of the second block should be:

echo fix_name("costa playa");
broj1 356 Humble servant Featured Poster

You probably have a quantity in input field and total somewhere in text (i.e in a div or span element). Both elements should have unique ID so their values can be read by javascript. In addition you should have a button with onclick event attached that fires your javascript function.

Html code:

<form>
<input type="text" ID="quantity" /><br />
<input type="button" onclick="calculateTotal()">
</form>
<div id ="total"></div>

Javascript code is:

function calculateTotal() {

    // price per unit 
    var price = 30;

    // get input element from DOM
    var inputEl = document.getElementById('quantity');

    // read quantity from the input element (it is read as a string)
    var quantitySting = inputEl.value;

    // convert string value from the form element into integer (or float if needed)
    var quantity = parseInt(quantitySting);

    // calculate total
    var total = price * quantity;

    // get element that displays total from DOM
    var displayEl = document.getElementById('total')

    // display total value in target element
    displayEl.innerHTML = total;
}

This is more or less basics of getting the value from input and displaying some text in another element on page. You should improve things here (like checking whether entered value is valid, adding currency symbol, or have a select element with preset quantity values and onchange event instead of onclick etc), but in a nutshell this is it.

broj1 356 Humble servant Featured Poster

I use TCPDF which is licenced as LGPL and available at:

http://www.tcpdf.org/

There are plenty of examples on the site to get you started:

http://www.tcpdf.org/examples.php

broj1 356 Humble servant Featured Poster

See an example here:

http://www.daniweb.com/web-development/php/code/379236/page2

Have look at the last post with improved code (the code in the first post was criticised rightly for lack of security measures).

broj1 356 Humble servant Featured Poster

There are a couple of mistakes in your code:
1. you declare $nome=$db_field; on line 19 and then use value="$nsme" on line 39 (typo?)
2. you declare $cognome=$db_field; on line 20 and then use value="$gender" on line 43 (shouldn't it be value="$cognome")
3. your <'php opening tag is not followed by a ?> closing tag somewhere before html code
4. your html code is within PHP block (see 3. above) which causes errors
5. in html you must echo variables enclosed in php tags

See the example of how this code should look like:

<?php

include 'complete.php';

    $user_name = "exa";
    $password = "exa";
    $database = "exa";
    $server = "localhost";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "SELECT * FROM tb_exa WERE username='$CCGuser' AND password='$CCGpassw'";
$result = mysql_query($SQL);

while ($db_field = mysql_fetch_assoc($result)) {
$nome=$db_field['name'];
$cognome=$db_field['gender'];
}

mysql_close($db_handle);

}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}

?>
 
    

    <table style="width: 100%">
    <form action="process_u.php" method="post">
        <tr>
            <td>Name: </td>
            <td> <input type="text" name="name" value="<?php echo $nome;?>"></td>
        </tr>
        <tr>
            <td>Gender: </td>
            <td> <input type="text" name = "gender" value="<?php echo $cognome;?>"></td>
        </tr>

 <input type="submit" value="GO" name="Submit">&nbsp; <input type="reset" name="reset" value="Reset" /></td>
            <td>&nbsp;</td>
        </form></tr>
    </table>
broj1 356 Humble servant Featured Poster

The information about the book I mentioned: PHP6 and MySQL Bible (PHP 6 is not out yet but the book is OK for PHP 5 too), published by Wiley. Authors are Steve Suehring, Tim converse and Joyce Park. The link on Amazon:

http://www.amazon.com/PHP6-MySQL-Bible-Steve-Suehring/dp/0470384506

I read this book from cover to cover and gave me realy good insight in PHP so I realy never had a need to look into many other books. Anther one very useful for web development is Scriptin' with JavaScript and Ajax: A Designer's Guide (not exactly PHP but you might need it), writen by Charles Wyke-Smith, see:

http://www.amazon.com/Scriptin-JavaScript-Ajax-Designers-Voices/dp/0321572602/ref=sr_1_3?s=books&ie=UTF8&qid=1319009826&sr=1-3

broj1 356 Humble servant Featured Poster

Thats why we are here for:-). But do not forget to improve the code with security measures.

broj1 356 Humble servant Featured Poster

Also line 19

if(mysql_num_rows($query1)>0)

should be

if($query1 and mysql_num_rows($query1)>0)

since query1 is false when wrong username or password. And also initialize $msg first. Put the following code say on line 12:

$msg = '';

.

broj1 356 Humble servant Featured Poster

You need:
1. an editor that helps PHP development. PHP Eclipse (http://www.phpeclipse.com/g) and Netbeans (http://netbeans.org/) are probably most wide spread but for a beginner maybe a little overwhelming. Notepad++ (Windows) and Kwrite, gedit (Linux) are simpler and still powerfull ones.
2. a PHP and mysql enabled web server (can be on your machine or at your ISP). If on your machine try LAMP on Linux (see your distribusion package management) or XAMP (http://www.apachefriends.org/en/xampp.html) on Windows) that both contain Apache web server, Mysql database and PHP support.
3. good book to learn (I used PHP5 and MySQL Bible)
4. links: http://www.w3schools.com/php/, www.php.net, daniweb.com :-)

broj1 356 Humble servant Featured Poster

On Linux (maybe on Windows too) you can use mysqldump command to backup mySql database in a SQL script. Optionaly the script can be compressed (gzipped in this example).

// username, password, mysql host, database name
$dbuser = 'yourMysqlUsername';
$dbpw = 'yourMysqlPassword';
$dbhost = 'yourMysqlHost';
$dbname = 'yourMysqlDatabaseName';

// valid path to a directory where the database will be backed up
$backupPath = 'some valid path like /var/www/db_backup/';

// the name of the backup file
$backupFile = $backupPath . $dbname . '_' . date("Y-m-d-H-i-s");

// command for dumping database
$dbdumpcmd = "mysqldump --opt -v -h $dbhost -u $dbuser -p'$dbpw' $dbname";

// Option 1: a command to backup in a SQL file
$command = "$dbdumpcmd > $backupFile.sql";

// Option 2: a command to backup in a gzipped SQL file
$command = "$dbdumpcmd | gzip > $backupFile.gz";

// execute the command
system($command);
broj1 356 Humble servant Featured Poster

Move the curly brace form line 49 to a line 29. Your second if block should be a part of your first if block which means if form has been submitted and if password is correct then display the greeting else display the table with the form. See the code below.

There are other issues like security. Clean your input to prevent nasty guys and girls to inject nasty code.

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Latest</title>
</head>

<body>

<?php
include("db.php");

if (isset($_POST["submit"]))
{
$username=$_POST["username"];
$password=$_POST["password"];
$query="select * from latest where username='$username' && password='$password'";
$query1=mysql_query($query);
if(mysql_num_rows($query1)>0)

{?>

<font color="#FF0000" size="+4"><b>
<?php  

 echo "welcome";
 echo ($username);

}
}
else 
{

?>
 

<center>
<table align="center" border="2">
<form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']  ?>" method="get">
<tr><td></td></tr>
<tr><td>Enter Username</td>
<td><input type="text" name="username" />
</td></tr>
<tr><td>Enter Password</td>
<td><input type="password" name="password" /></td>
</tr>
<tr><td>Submit</td><td><input type="submit" value="submit" name="submit"/></td></tr>
</form>
<?php } ?>
</table>

</center>
</body>
</html>
broj1 356 Humble servant Featured Poster

You can not change a session variable from your page without sending a http request to the server. If you do not want to refresh the page you have to use Ajax. So when user clicks something on your page (maybe a select element) javascript function hooked to that event sends http request to the server script that updates the session variable and response of the request is used to update another element on the page (again with javascript). Search for Ajax examples on this forum or elsewhere. You should find plenty of explanations (sorry to direct you to google since I am very short on time at the moment).

broj1 356 Humble servant Featured Poster

You can not access the class variable that has been declared as private from outside the class. You either declare it public (instead of private) which is really not a good practice or add a method that returns the value of the variable.

class bag{
  private $no_of_items=0;
  private $sub_total;

  public function update(){
  $this->no_of_items = $this->no_of_items++; 
  return true; 
  }

  public function get_no_of_items() {
    return $this->no_of_items;
  }
}

Get the number of items:

echo $cart->get_no_of_items();

I am not sure if this is the core of your problem though.

broj1 356 Humble servant Featured Poster

I use Pager from the Pear framework. Have a look at

http://www.alberton.info/pear_pager_tutorials.html

and

http://pear.php.net/package/Pager/docs

Unfortunately you have to be familiar a little with how to install Pear components but it is not very hard.

broj1 356 Humble servant Featured Poster

You will probably have to do some basic debugging like put echo or die statement to examine your query. I would put a line after line 2 (comment section):

echo($query_news);

and then copy the displayed query from the browser to phpmyadmin (or any other gui to mysql server or even through shell) and run it there. Then you can see exactly what query gets passed to the server and whether there are any records that should be returned.

broj1 356 Humble servant Featured Poster

I thing the cause of trouble could be in your query in a comment section (line 2):

$query_news = ("SELECT * FROM newscomments WHERE nid = id");

id should probably be a PHP variable, maybe $id? Just a guess.

$query_news = ("SELECT * FROM newscomments WHERE nid = $id");
broj1 356 Humble servant Featured Poster

Sorry, I have just noticed that you said that you want to print the other page. I guess that if you want to print form the browser using javascript that page has to be open in a window. So one optin is to open the other page in a new window and launch javascript function for printing form onload event. Maybe these discussions give you some hints:

http://www.webmasterworld.com/javascript/3524974.htm
http://www.highdots.com/forums/javascript/printing-another-web-file-present-274201.html

Another option would be to generate pdf (or doc) on the fly from the html of the other page and let user print the pdf which is much better for printing than hrml. I use TCPDF library for that and it works like a charm once you get used to it.

broj1 356 Humble servant Featured Poster

I managed to run above code without errors (both tables were created). If this helps you: my MySql server version is 5.1.46, both tables were created by default as MyISAM type.Maybe you find useful info on foreign keys here:

http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-foreign-keys.html. Maybe tables should be of InnoDb type. Just a guess.

broj1 356 Humble servant Featured Poster

Use Javascript for printing. The view button type attribute should be 'submit' while the print button type attributeshould be just 'button'. Then asign a javascript function to the print button like this:

<input type="button" onClick="window.print()">
broj1 356 Humble servant Featured Poster

My guess: make sure that table book does not already exist. Add IF NOT EXISTS to the query.

CREATE TABLE IF NOT EXISTS book(
bookid SMALLINT(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(bookid),
author VARCHAR(30),
title VARCHAR(30),
accessno INT(20),edition INT(20),publisher VARCHAR(30),
copies INT(10),
status VARCHAR(30),CONSTRAINT fkbook FOREIGN KEY (status)
REFERENCES issue(status))
broj1 356 Humble servant Featured Poster

Glad it helps.

broj1 356 Humble servant Featured Poster

One way of doing it:

$brush_price = 5;
$counter = 10;

// row for quantities with heading in first cell
$qtyRow = '<tr><th>Quantity</th>';

// row for prices with heading in first cell
$priceRow = '<tr><th>Price</th>';

// add cells to each row
while ( $counter <= 100 ) {

    $qtyRow .= "<td>$counter</td>";

    $priceRow .= "<td>" . ($brush_price * $counter) . "</td>";

    $counter = $counter + 10;
}

// end of the rows
$qtyRow .= '</tr>';
$priceRow .= '</tr>';

// echo the table
echo "<table border=\"1\" align=\"center\">";
echo $qtyRow;
echo $priceRow;
echo "</table>";
broj1 356 Humble servant Featured Poster
broj1 356 Humble servant Featured Poster

Just to help you a little bit here is the code for easier debugging:

<?php
$query = "SELECT * FROM tbl_users WHERE ex_date between now() and adddate(now(), INTERVAL 7 DAY) ORDER BY user_id ASC";
$result = mysql_query($query);

$num = mysql_numrows($result);

/* DEBUG CODE*/
echo "<p>Number of rows: $num</p>";
/* END DEBUG CODE*/

$i = 0;

while ($i < $num)
{
    $id = mysql_result($result,$i,"user_id");
    $email = mysql_result($result,$i,"login_email");
    $loginname = mysql_result($result,$i,"loginname");
    $ex_date = mysql_result($result,$i,"ex_date");
    $ex_date = date("d-m-Y", strtotime($ex_date) );

    //send email

    $to = "$email";

    $subject = "Expriy Notice";

    $from = "Admin";

    $msg = "Hello $loginname,<BR><BR>";
    $msg .= "Your Account will expire in 7 days. Your Expiry Date is $ex_date<br /><br />";
    $msg .= "Regards: <br /><br />Admin";
    $msg .= "Admin";

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "From: Admin\r\nReply-To:sammy@gmail.com" . "\r\n";

    /* DEBUG CODE*/
    echo "<p>Variable i: $i<br />";
    echo "Email: $to<br />";
    echo "Subject: $subject<br />";
    echo "Message: $msg<br />";
    echo "Mail code: mail($to,$subject,$msg,$headers)</p>";
    /* END DEBUG CODE*/

    // Temporarily commented out
    // $mailsend = mail($to,$subject,$msg,$headers);

    // Temporarily commented out
    // echo $mailsend ? "Email was sent :-)." : " Email sending failed.";

    $i++;
}
?>

It might help if you post what gets displayed in your browser.

broj1 356 Humble servant Featured Poster

Can you put the if block in the while loop (on the end of the loop), insert this code before the end line in if block and post the result:

echo "<p>Variable i: $i<br />";
echo "Email: $to<br />";
echo "Subject: $subject<br />";
echo "Message: $msg</p>";

Other remarks:

You should change the code on line 42 to

$msg = "Hello $loginname,<BR><BR>";

(no concatenation on the beginning of building up a message, oterwise the $msg will grow).

The quotes arround the mail function parameters are unnecesary (they cause unnecesary parsing of variables in strings).

All code could be in one block of <?php ?>

broj1 356 Humble servant Featured Poster

But was the list of emails correct (only the users that were supposed to get the mail)?

broj1 356 Humble servant Featured Poster

Also, what is the point in a condition in line 30

if($query == TRUE)

which is always true?

broj1 356 Humble servant Featured Poster

Your query should return only records for users whose expiry date is 7 days or less. That is why your mailing code should go into the while loop which steps through the result set. I suggest you check what your query returns. comment out lines 60 and 62 and add this code on line 63:

echo "$email<br />";

That should list emails that are supposed to get the message. Make sure that the query returns the emails you expect.

broj1 356 Humble servant Featured Poster

Depends on the operating system on your VPS ant the service in question I guess. If it is Linux you can use the following command to enable e.g. the Apache webserver service which will still run after you log out (on Fedora 15):

/sbin/chkconfig httpd on

Service control is becoming a part of systemd these days. See mapping of command here: http://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet.

broj1 356 Humble servant Featured Poster

To try to help with first question: onclick event can call only javascript function (I think) so you can write one and use window.open('./downloads/') javascript built in method or window.location='./downloads/'.

broj1 356 Humble servant Featured Poster

In the second situation use two div elements each containing the form elements for one radio button and one div being visible (display:block) and other hidden (display:none). Radio buttons should have JS code which is fired on onclick event and toggles the visibility of both div elements.