Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

php email validation example

Here is the code to validate email address



<?php

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email)){
echo "Invalid email";
}else{
echo "Valid Email";}

?>

create gridviews with sigmawidgets [javascript,ajax]

Sigma grid is Written in pure javascript, Sigma Grid is an Ajax data grid for displaying and inline editing data in a scrollable and sortable table. With MVC architecture, plenty of attributes and powerful script API, this grid control brings developer more flexibilities and less workload.

For more details visit :sigmawidgets

php functions explained -- func_num_args() and func_get_args()

1. func_num_args()
2. func_get_args()

These are two php functions used to find number of arguments passed to a function and get get argument values.

For more details visit php manual

why this functions?

These functions are used in function oveloading to find number of arguments passed and there values. .
Usual method of function overloading not works in php.

Pass array in php from one php page to other

Here is a simple way to pass your array in post method.

In first page we are creating a form.In that form creating hidden 
controls with arrray value as shown below.

In second part (display.php) we can extract values from request 
variable. 
Here is the code 
 
///////////////////////////////////////////////////

echo '<form name="form" method="post" action="display.php">';


$i=0;

foreach($arr as $key => $value)
{
$i++;
echo '<input type="hidden" name="val['.$i.']" value="'.$value.'"/>';
}

echo '</form>';







////////////////Copde in display.php page ////////////////



foreach($_REQUEST['val'] as $key => $value)
{


echo $value;
}

//////////////////////////////////////

If you found some good method to pass array Share with us as comments 
with regards SREEHARI