Will Gresham 81 Master Poster

The rewrites will be the easy part as these are just REGEX in your .htaccess file.

The rest of the work would be a huge task, all your links on all pages would need to be updated to the new format.

Take a look at http://www.workingwith.me.uk/articles/scripting/mod_rewrite for rewrite descriptions and tutorials.

Will Gresham 81 Master Poster

I have broken up the code with the required changes as below:

<?php
$m = (!$m) ? date("m",mktime()) : "$m";
$y = (!$y) ? date("Y",mktime()) : "$y";

Changes Here

if (isset($_POST['Submit7']))
{
$eventdate = $_POST['eventdate'];
$stime = $_POST['stime'];
$location = $_POST['locate'];
$mdescription = $_POST['description'];

header('location:next.php');
exit();
}

Remove reset code

?>
<html>
<table>
<tr>
<!-- calling the function to draw the calendar -->
<td valign="top"><?php cal($_GET['m'],$_GET['y']); ?></td>
<td width="25" nowrap><br /></td>
<td> </td>
<td>
<!-- the second column of the table starts here -->
<!-- -->
<form name="me" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#000000"><tr><td>
<table cellpadding="4" cellspacing="1" border="0 "bgcolor="#FFFFFF">
<tr><td colspan="2" bgcolor="#3399FF"><font size="+1" color="#FFFFFF"><b>Request Form</b></font></td></tr>
<tr><td><b>Date for Event: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">dd/mm/yyyy</font></td></tr>
<tr>
<td><b>Start Time:</b></td>
<td><input type="text" name="stime"> 24 Hour Format ie.1125 </td>
</tr>
<tr>
<td><b>Location:</b></td>
<td><input type="text" name="locate">20 Characters</td>
</tr>
<tr>
<td><b> Description:</b></td>
<td><textarea name="descrption"></textarea></td>
</tr>
<tr>
<td colspan="2" bgcolor="#3399FF"><div align="center">

Changes Here

<input type="reset" name="Submit6" value="Reset"> &nbsp; &nbsp; &nbsp; &nbsp;
<input type="submit" name="Submit7" value="Next">
</td>
</tr>
</table></form>
</table>
</blockquote>
</body>
</html>

This should do what you want.

Will Gresham 81 Master Poster

You would be looking at AJAX(JavaScript) to don this without the page reloading and a database to store the image locations in and populate the lists in order to do this.

Will Gresham 81 Master Poster

The simplest way to do this would be to read the number of active sessions as nikesh.yadav said.

I have added the code I use on my sites to give an example:

<?
$number=0;
// define the directory to save sessions in
session_save_path("session_directory");
session_start();
// set the session as active
$_SESSION['active']="yes";
$directory = opendir("sessions");
while($item = readdir($directory))
{
  if(($item != ".") && ($item != ".."))
  {
// count the number os sessions active within the last x sexonds
    if(fileatime('sessions/' . $item) > time()-120)
    {
// add 1 to the session count
      $number++;  
    }
  }
}
closedir($directory);
session_unset();
// return the value
return ($number=='1') ? "There is " . $number . " user online now." : "There are " . $number . " users online now."; 
?>
Will Gresham 81 Master Poster

If you want to do this without reloading the page, you will need to look into JavaScript (specifically, AJAX if this is connected to a database)

If you are happy to reload the page, you would need to employ some kind of session or cookies to keep track of rows on the page.

We would need some more information or your source code to know exactly what you are looking for.

Will Gresham 81 Master Poster

Not quite

$_POST is the item to use for the if statement.

What this does is gets the value for the field in the form which is named in quotes.

You don't need anything but <input type="submit" name="Submit7" value="Next" /> for the submit button, the method=post is defined by the <form> tag.

All you need for the if statement is the code I posted earlier, if (isset($_POST['Submit7'])) { this says 'If Submit7 has been pressed, run the following code'.

Will Gresham 81 Master Poster

There are many scripts available online which will do what you are looking for..

You would need to look into security and many other areas to get this working correctly, it would be easier to use a pre-made script.

Will Gresham 81 Master Poster

Make sure you put your code in code tags.

if (($_SERVER['REQUEST_METHOD'] == "POST") || ($_SERVER['Submit7'] == "Next"))
{
$eventdate = $_POST['eventdate'];
$stime = $_POST['stime'];
$location = $_POST['locate'];
$mdescription = $_POST['description'];

header('location:next.php');
exit();
}

Would it not be better to replace the IF statement with

if (isset($_POST['Submit7'])) {

This will check whether the submit button has been clicked, also I don't believe $_SERVER can be used to check form fields, check http://uk3.php.net/manual/en/reserved.variables.server.php.

Also, can I ask why you aren't using the reset button in HMTL? <input type="reset"> as this will clear all fields in the form.

Will Gresham 81 Master Poster

Are you storing this in the database as a timestamp, date, or string?

One way to convert it is when you fetch the date from the table convert it to the correct format:

$split_date=explode("/", $date_var);
$date=$split_date[2] . "/" . $split_date[1] . "/" . $split_date[0];

Depending on which format you store the date as in the database there may be easier ways of doing this.

Will Gresham 81 Master Poster

Instead we can use simply:

$currentFile=basename($_SERVER['PHP_SELF']);

That would be the better way, yes. Forgot about that one :)

Will Gresham 81 Master Poster

If I am understanding you correctly, the following should work:
In the script containing the <head> add something like this inside the <head></head> tags:

<?
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$currentFile = $parts[count($parts) - 1];

if($currentFile == 'admin.php') {
  //put JS code here
}
?>

This will mean that the JavaScript code will only be loaded with the admin.php script and you can then use the onload function.

Will Gresham 81 Master Poster

One way to do this would be to include an if statement and a counter for example,

$counter=0
while(sql_statement) {
$id=$row['id'];
$date=$row['date'];

$sentby=$row['sender'];
$comment=$row[comment];

if($counter==4) {
echo "<br />";

// reset the counter
$counter = 0;
}
echo"sent by: $sentby Comment:$comment  date sent:$date";
$counter++;
}
Will Gresham 81 Master Poster

This is fairly simple, use the RAND function in the SQL query:

$sql = "SELECT * FROM tablename WHERE somefield='something' ORDER BY RAND() LIMIT 10";
Shanti C commented: Nice Answer.... +2
Will Gresham 81 Master Poster

As far as I am aware this can only be done with the ID3 library (unless you name the MP3's in a standard format such as Artist-Genre-Song.mp3)

If ID3 already exists and is the standard why would you want to make your own methods?

I know you said without ID3 but take a look at the project page http://getid3.sourceforge.net/

Will Gresham 81 Master Poster

Personally I would not use the second example-saving images into the Database, there is no need.

The filesystem was designed to do this job so why re-invent the wheel? I have yet to come across a scenario where storing images in the database is better than the filesystem.

Will Gresham 81 Master Poster

There is no way to hide HTML or JavaScript code from the user, these are client-side scripts and will need to be processed by the client browser, as such the code will need to be sent and can be viewed. The PHP code cannot alter this since it is a server-side script is processed into HTML output before being sent.

Will Gresham 81 Master Poster

I would have thought this goes in the HTML/CSS forum here
Although I would suggest running the page through a validator (http://validator.w3.org/) first since there are multiple problems on all pages.

Will Gresham 81 Master Poster

Simply use the HTML a tag to make it a hyperlink

<a title="link_title" href="link_here"><? echo $rows['topic'];?></a>

In the database you also need to have the unique identifier for the row and make the link something like mypage.php?topicid=ID where ID is the identifier.

Will Gresham 81 Master Poster

Just store the numbers with the decimal value, if they are in a MySQL database there is a DECIMAL datatype for this, in MSSQL there is a CURRENCY one. If the values are hard-coded into the scripts, just add .00 to the end of them.

If I am missing the point please provide a code example as you are giving little to go by on what you want.

Will Gresham 81 Master Poster

The POST data is cached by the browser, which is why in most cases when you refresh a page with POST data the browser will ask if you want to re-submit it (as well as when you go back to the page with the data on).

The other option you can look into is setting a no-cache in the header of the dosument, detailed at http://uk2.php.net/header

Be aware that if there are times that you want the browser to store page details and refer to POST and GET this may mean you need a work-around for that

Will Gresham 81 Master Poster

The GD Library will alow you to add text to an image, the GD library can be obtained from http://www.libgd.org/Main_Page

Will Gresham 81 Master Poster

Can you give an example of what you are actually trying to acheive, PHP doesn't work with datatypes in the same way as many other scripting/programming languages.

Read the last paragraph on http://phpbuilder.com/manual/en/language.types.string.php

Will Gresham 81 Master Poster

at the start of search-exec.php

Follow that ^

Will Gresham 81 Master Poster

I would suggest doing something like the following:
Create a new page (such as process.php) and put the following code into it:

<?
session_start();
//Store the POST and GET data into the session
$_SESSION['post_data'] = $_POST['test'];
$_SESSION['get_data'] = $_GET['test'];

//Redirect to the correct page
header("Location: index.php?test=hi");
?>

This will register the values to a session, and then because you are navigating away from the page with the header redirect you the POST data will be deleted automatically.

You will then need to add session_start() to the top of index.php and change

echo 'Post data: ' . $_POST['test'] . '<br>';

and

echo 'Get data: ' . $_GET['test'] . '<br>';

to

echo 'Post data: ' . $_SESSION['post_data'] . '<br>';

and

echo 'Get data: ' . $_SESSION['get_data'] . '<br>';

respectively.

Will Gresham 81 Master Poster

Have you cheked where the server is looking for the font and that the ttf file is in the correct directory on the server?

Will Gresham 81 Master Poster

can you use this code and let us know what it returns:

<?php

   mysql_connect("localhost","root","password");

   $tables = mysql_list_tables("test");

   while (list($table) = mysql_fetch_row($tables)) {
      echo "$table <br />";
   }

?>

obviously change the password to your password.

Will Gresham 81 Master Poster

Do you have a table called 'test' within the database 'test'?

change $res = mysql_query($sql); to $res = mysql_query($sql) or die(mysql_error()); Does this return an error?

Will Gresham 81 Master Poster

look at the code below where you highlighted line 83, you have

echo $row['Competition2'] . " " . $row['Sport2'] . " " . $row['Country2'] . " " . $row['Time2]; echo "</h8><br><h7>";

you are missing a ' from $row['Time2] this is also missing in the ones following this as well.

Will Gresham 81 Master Poster

1. Lookup the update statement on the internet, the syntax for it is not correct, you can't simply replace INSERT with UPDATE, you need to completely re-write it, basics below:

mysql_query("UPDATE table_name SET row_name = value, rowname = value WHERE row_name = 'value'");

2. Are there any unescaped quotes within the values in the database as these may through such errors
For example, if you had 'value' in Team5 row in the database, it would make the code echo $row['Team5'] ..... into echo $row[''value'']...... which results in value being seen as code.
If you have any ' or " in the values in the db, you can escape them by changing them to \' or \"

Will Gresham 81 Master Poster

A quick web search will bring up the answer you are looking for, the option is called Indexes in the Options within the htaccess file add Options -Indexes (if you already have some Options listed, add the -Indexes to the end.

Further reading:
http://www.clockwatchers.com/htaccess_dir.html

Will Gresham 81 Master Poster

Do you have a re-direct on the logout.php script? If you do comment this out and run the code to see if the cookies are being deleted at all, its possible depending on how your script works that it is re-creating the cookies when the user is re-directed.

The code is not browser defendant since PHP is a server side language not client side.

Personally I use the following code to delete cookies, but it does exactly the same as the previous examples:

$past = time() - 3600;
	setcookie('cookie_name', null, $past);
Will Gresham 81 Master Poster

I have upgraded to Firefox 2.0.0.14 on openSuse 10.3 and then downloaded Java 6u6 and installed that, created a symbolic link to java plugin for firefox but whenever I try to load a Java applet it will not show anything, not even the jigsaw piece saying Java is not installed.

Looking at about:plugins it shows java as installed and active.

I tried going back to the previous version of Firefox (2.0.0.6) and the previous version of Java (cant remember the version) and firefox just crashes.

Any ideas?

Will Gresham 81 Master Poster

In the httpd.conf file you should have a line similar to DirectoryIndex index.html Change this to DirectoryIndex index.php

Will Gresham 81 Master Poster

Not sure exactly how variable variables work, but the PHP manual about them is here

Will Gresham 81 Master Poster

The best way to do this would probably be an array:

$abc=array("value1","value2");

for($i = 0; $i < 2; $i++) {
echo $abc[$i];
}
Will Gresham 81 Master Poster

ah ok, didn't even think about that being turned off as it is usually on by default. :)

Will Gresham 81 Master Poster
<?php
error_reporting(E_ALL);
// Show simple format of the records so person can choose the reference name/number
// this is then passed to the next page, for all details

$host = "localhost"; 
$user = "xxx"; 
$pass = "xxx"; 
$db = "phonebook"; 

//Connecting to MYSQL
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

//Select the database we want to use
mysql_select_db($db) or die ("Could not find database");

// Get all records in all columns from table and put it in $result.
$query = "SELECT * FROM people ORDER BY fname ASC"; 

// execute query 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

// Get all records in all columns from table and put it in $result.

if (mysql_num_rows($result) > 0) {
  while($row=mysql_fetch_row($result)){
    echo "ID : $row[0] <br/>";
    echo "First Name : $row[1] <br/>";
    echo "Last Name : $row[2] <br/>";
    echo "Phone Number : $row[3] <br/>";
    echo "Extension : $row[4] <br/>";
    echo "Title : $row[5] <br/>";
    echo "Department : $row[6] <br/>";
    echo "Fax Number : $row[7] <hr>";
    // Add a link with a parameter(id) and it's value.
    echo '<a href="phoneupdate1.php?id='.$row[0].'">Update</a>';
  }
} else { 
  // no 
  // print status message 
  echo "No rows found!";
} 
//mysql_close();
?>
Will Gresham 81 Master Poster

We need a little more information on what you want to do;
Do you have passwords in a database, htpasswd file, or other means?
Do you have any code at the moment and what does it do?
are the passwords encrypted or plain text?

Will Gresham 81 Master Poster

Before the form you will need to generate the random number, also you have specified no value for the hidden field, change method= to value=.

To generate the random number do something like this:

<?
// mt_rand(min value, max value)
$rand = mt_rand();
?>
Will Gresham 81 Master Poster

I have it working here: http://www.elvenblade.com/test/ with the code I posted in post 29

Will Gresham 81 Master Poster

try changeing these <? echo $row[number]; ?> to these <?=$row[number]?> in the HTML form.

Will Gresham 81 Master Poster

could the problem be on the first form, at the:

echo '<td><a href="phoneupdate1.php?id='.$row[0].'">Update</a></td><br/><hr>';

area? Maybe its not passing the id to the next form. Is there a way to test this?

No, that is right, $row[0] refers to the column id in the database, the easy way to check, click it and see if the correct number shows up in the URL on the next page :)

http://www.elvenblade.com/test/ - that is the script I posted in my previous message, it all seems to be working there.

Will Gresham 81 Master Poster

make sure that the location in the header() redirect is correct.

Will Gresham 81 Master Poster

what error do you get on submitting?

Will Gresham 81 Master Poster

Right, I think this will sort it, I have run the script on my pc with no errors.

I have made a couple of changes to the script, these are in bold.

<?php
error_reporting(E_ALL);

$host = "localhost";
$user = "xxx";
$pass = "xxx";
$db = "phonebook";

//Connecting to MYSQL
[B]mysql_[/B]connect("$host","$user","$pass");
//Select the database we want to use
mysql_select_db($db) or die("Could not find database");


// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
[B]if(isset($_POST['Submit'])){[/B]

// Get parameters from form.
$id=$_REQUEST['id'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone_num=$_POST['phone_num'];
$ext=$_POST['ext'];
$title=$_POST['title'];
$dept=$_POST['dept'];
$fax=$_POST['fax'];

// Do update statement.
mysql_query("UPDATE [B]people[/B] SET `fname`='$fname', `lname`='$lname', `phone_num`='$phone_num', `ext`='$ext', `title`='$title', `dept`='$dept', `fax`='$fax' where `id`='$id'")[B]or die(mysql_error());[/B]

// Re-direct this page to select.php.
header("location:phoneupdate.php");
exit;
}
// Check to see if the link from the previous page was clicked
if(isset($_REQUEST['id'])) {
  // Check that the id value in the URL is a number
  if(is_numeric($_REQUEST['id'])) {
    $id=$_REQUEST['id'];
    $result=mysql_query("SELECT * FROM people WHERE id = '$id'") or die(mysql_error);
    i[B]f(mysql_num_rows($result) > 0) {[/B]
      $row=mysql_fetch_row($result);
    } else {
      echo 'No Record';
    }
  }
}
// ************* End update part *************

// Close database connection.
mysql_close();
?>

<!-- END OF PHP CODES AND START HTML TAGS -->
<html>
<body>
[B]Reference: <?=$id?><BR>[/B]
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action=[B]"<?=$_SERVER['PHP_SELF']?>?id=<?=$id?>">[/B]
<p>First Name :
<!-- name of this text field is "fname" -->
<input name="fname" type="text" id="fname" value="<? echo $row[1]; ?>"/>
<br />
Last Name :
<!-- name …
Will Gresham 81 Master Poster

change

mysql_query("update phonebook set First Name='$fname', Last Name='$lname', Phone Number='$phone_num', Extension='$ext', Title='$title', Department='$dept', Fax='$fax' where id='$id'");

to

mysql_query("update phonebook set `fname`='$fname', `lname`='$lname', `phone_num`='$phone_num', `ext`='$ext', `title`='$title', `dept`='$dept', `fax`='$fax' where `id`='$id'");
Will Gresham 81 Master Poster

this part of your code is incorrect, you don't have any POST data from the previous page so $_POST will return a null value, remove this:

// *** Select data to show on text fields in form. ***

// Get id parameter (GET method) from select.php
$id=$_POST['id'];

// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("select * from people where id='$id'");

// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);

as it is basically duplicating this part (move this to below the comment stating the end of the update if you wish):

// Check to see if the link from the previous page was clicked
if(isset($_REQUEST['id'])) {
  // Check that the id value in the URL is a number
  if(is_numeric($_REQUEST['id'])) {
	$id=$_REQUEST['id'];
    mysql_query("SELECT * FROM people WHERE id = '$id'") or die(mysql_error);
    if(mysql_num_rows > 0) {
      $row=mysql_fetch_row($result);
    } else {
      echo 'No Record';
    }
  }
}

Also, can you list the column names from the database.

Will Gresham 81 Master Poster

Whats the code you are actually using at the moment.

Will Gresham 81 Master Poster

sorry, spotted another problem with my code, change

if(is_numeric($_REQUEST['id'])) {
    mysql_query("SELECT * FROM people WHERE id = `$id`") or die(mysql_error);

to

if(is_numeric($_REQUEST['id'])) {
    $id=$_REQUEST['id'];
    mysql_query("SELECT * FROM people WHERE id = `$id`") or die(mysql_error);

otherwise the script isnt being told which ID to get :)

Will Gresham 81 Master Poster

In the SQL update query, put the field names in ``, also the names such as First Name and Last Name do not look correct, make sure that the names you use in the query are exactly what shows on the database (through phpmyadmin or similar)

The $_POST[] values are fine, they relate to the input fields on the form so that is not a problem.

Also, your SQL update query uses $id which has not been passed to the function from the form, change the form action from "<? echo $PHP_SELF; ?>" to "<? echo $PHP_SELF; ?>?id=$id" and change

// Get parameters from form.
$id=$_POST['id'];

to

// Get parameters from form.
$id=$_REQUEST['id'];