Re: [PHP] Right Click Hyperlink

2003-07-31 Thread Joona Kulmala
Does anyone know if there is anything in PHP or any other language that 
would

allow a specific action to occur if a visitor right-clicked on a 
link.  For example, they could left click on it an go to a specified 
page, and they could also right-click it to go to a different page.  
Anyone know of anything that can do this?
 

It isn't possible with PHP, becaus PHP is Server Side Language, so it isn't
capable to handle browser events. But this is possible with javascript.
It should go like this:

  your link
If you wan't more info, aske Google:
  - 
http://www.google.com/search?num=100&hl=en&lr=&ie=UTF-8&oe=utf-8&q=javascript+onRightClick&btnG=Google+Search 



Greetings, Joona

--
Joona Kulmala <[EMAIL PROTECTED]>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Form Retain Info on Back?

2003-07-31 Thread Joona Kulmala
Hi

I have a php form that I run a test to see if they have entered in
all required fields before inserting into a MySQL db.  The PHP script
simply reports what is missing and exits the rest of the page.
However, when you click the back button, all the information that was
entered, is gone.  Is there a simple way of retaining this
information so the user doesn't has to retype all the information in?
If you had a MySQL connection, I think that the easiest (also most safe
and stable) solution would be putting the POST-data and error-report
to session/temporary mysql-table. I've used this kind of solution on
several projects and it has work pretty well. In this you'll also need
to set some information to cookies so user must have cookies enabled on
his/her browser.
* MySQL-table

I've been using specifid session-table in my projects, which also
carries logged users sessionid and other session-data. But you can
also create specific temp-table for incomplete form-data. It could
be something like this
[sql]

CREATE TABLE temp_form_data (
id int(10) UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
stamp int(10) NOT NULL,
data blob NOT NULL,
error blob NOT NULL
);
[/sql]



* Form prosessing

Then in the form prosessing you could make some kind of error array
where to include error information. If any errors occur, save post
and error data to mysql and set cookie with mysqls
mysql_insert_id()
Example:
[code]
$error = array();

// validate fields how you like, I do regexps.
// check for email-address field.
if 
(!preg_match('/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/', 
$_POST['mail'], $res))
{
// make an new index to $error array, you can assign any value
// you like for index.
$error['mail'] = 1;
}

// check if any errors occured
if (count($error) > 0)
{
// make a serialized dump of both $_POST and $error array
$dump_data = addslashes(serialize($_POST));
$dump_error = addslashes(serialize($error));
// build a sql-query to update form and error data to mysql
// table.
$sql  = "INSERT INTO temp_form_data ";
$sql .= "(date, data, error) ";
$sql .= "VALUES (UNIX_TIMESTAMP(),'{$dump_data}','{$dump_error}')";
// execute
if (mysql_query($sql))
{
// set cookie
setcookie('temp_form_data_id', mysql_insert_id());
// get user back to form.
// IMPORTANT: this must be before anything has been printed else
// it won't work.
header ("Location: form.php");
}
else
{
print "MySQL Error: " . mysql_error();
}
}
else
{
// FORM IS VALIDATED SUCCESFULLY
// insert data
}
[/code]

* Form itself

In form you have to first check if "temp_form_data_id" cookie exists.
If does, you should load saved form data from db. After loading data
you should check before every field does error array have index matching
fields name. You should also assign values to fields from db.
Here's an example:
[code]
if (isset($_COOKIE['temp_form_data_id']) && 
!empty($_COOKIE['temp_form_data_id']))
{
$id = $_COOKIE['temp_form_data_id'];

// select
$sql  = "SELECT * ";
$sql .= "FROM temp_form_data ";
$sql .= "WHERE id = {$id} ";
// execute
if ($q = mysql_query($sql))
{
// fetch row
$result = mysql_fetch_row($q);
// unserialize
$error = unserialize(stripslashes($result['error']));
$data = unserialize(stripslashes($result['data']));
else
{
print "MySQL Error: " . mysql_error();
}
}
if ($error) print 'Form was filled incorrectly';

print '';
if ($error['mail']) print 'Error: user valid email address';
print 'Email address:';
print sprintf('', $data['mail']);
print '';
[/code]

This is how it should work. I hope you get the picture.

Cheers, Joona.

--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is there an easier way?

2003-07-31 Thread Joona Kulmala
Ryan A wrote:
The problem is I have 38 fields and i can get upto 5 records that means
i will end up with over 150 of these statements:
$blahn=$data['blah'][n];
and since i dont want to go all over my script saying "echo
$data['blah'][n];" is there an easier way to avoid the 150 possible
statements? maybe via a for loop or something? Am feeling braindead right
now after sitting on the comp for 7hrs straight.
PHP has function which makes normal variables of associative array.

http://fi2.php.net/manual/en/function.extract.php

With this just try something like this:

[code]

extract($data);

// then you can see what happened
var_dump($blah, $secondindex, $thirdindex); // try here few index names
// from $data.
[/code]

I hope this will help you.

Cheers, Joona
--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Please Help

2003-07-31 Thread Joona Kulmala
My requirement is

1.I want to send video file using mail() function in PHP.So how to send
it.What is the procedure?
http://fi2.php.net/manual/en/ref.mail.php

Check out the templates, there is described how to build mail headers with
attachments. PHPs own mail function doesn't support this by default, thought.

2.How to delete one folder using PHP?
http://fi2.php.net/manual/en/function.unlink.php
http://fi2.php.net/manual/en/function.rmdir.php
Cheers, Joona
--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] eval

2003-07-31 Thread Joona Kulmala
Decapode Azur wrote:

Is it possible to put PHP code in eval ?
Or just vars ?


$string = 'The result of ';

eval ($string);

?>
It should go like:

[code]

eval('$var = "The result of"; $a=2; $b=3; $c = $a + $b; $var .= "$a + $b is $c";');

[/code]

Just a question, what are you really trying to do?

Cheers, Joona
--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Undefined variable problem

2003-08-01 Thread Joona Kulmala
Hello

This is the code:
   $m = 1;
   while ($line = mysql_fetch_assoc($rs)) { //dumping into an array
 foreach ($line as $field => $value) {
 $tmp = $field.$m;
$$tmp.= $value;  /* This is the error line 117*** */
 }
 $m++;
   }
This is basically so that i can use the array via variables like so:
if($tcl2==1){echo $tcl2;}
instead of: if($arrayname['tcl']['1']==1){echo $arrayname['tcl']['1'];} and
so onesp since i have 38 fields.
I can of course just shut off error reporting...but thats not the best
solution right? and i still wouldnt know whats causing these notices...
Simply define $$tmp -variable before adding stuff in it.

[code]
   $m = 1;
   while ($line = mysql_fetch_assoc($rs)) { //dumping into an array
 foreach ($line as $field => $value) {
$tmp = $field.$m;
$$tmp = "";
	 $$tmp .= $value; 
 }
 $m++;
   }
[/code]

No it should whine about undefined vars.

Cheers, Joona
--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Fusebox

2003-08-14 Thread Joona Kulmala
Ralph Guzman wrote:

I am trying to standardize my development process and have been looking
at the different frameworks out there.
One of the philosophies I like is that of Fusebox, although originally
developed for ColdFusion it is now available for PHP:
http://bombusbee.com/

Anybody have any experience working with Fusebox, or can anybody
recommend any other frameworks that I should also look at? I am looking
for a framework that will be developed going into PHP 5 also


Hi,

I don't know about Fusebox, but recommend Web Application Framework
called phpWebCore. This is simple and powerfull framework which has
ADOdb and Smarty implemented.
I've been also developing one whole summer in company I'm working for,
but maybe I'll release Open Source framework on my own later on.
You can find phpWebCore from:
http://phpwebcore.php
Cheers, Joona
--
Joona Kulmala <[EMAIL PROTECTED]>
PHP Finland 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php