Creating a Php Script to Mail Your Form

Php Mail Script

According to the form action in simple_form.html, you
 need a script called send_simpleform.php. The goal
 of this script is to accept the text in
 $_POST[sender_name], $_POST[sender_email],
and $_POST[message] format, send an e-mail, and
 display a confirmation to the Web browser.
Open a new file in your text editor.
Begin a PHP block, then start building a message string:

PHP script to process the form, send the mail






<?
$msg = "E-MAIL SENT FROM WWW SITE\n";

Continue building the message string by adding an entry for the sender's name:

$msg .= "Sender's Name:\t$_POST[sender_name]\n";


 Note  The next few steps will continue building the message string by concatenating smaller strings to form one long message string. Concatenating is a fancy word for "smashing together." The concatenation operator (. =) is used.


Continue building the message string by adding an entry for the sender's e-mail address:

$msg .= "Sender's E-Mail:\t$_POST[sender_email]\n";

Continue building the message string by adding an entry for the message:

$msg .= "Message:\t$_POST[message]\n\n";

The final line contains two new line characters to add additional white space at the end of the string.

Create a variable to hold the recipient's e-mail address (substitute your own):

$to = "you@youremail.com";

Create a variable to hold the subject of the e-mail:

$subject = "Web Site Feedback";

Create a variable to hold additional mailheaders:

$mailheaders = "From: My Web Site <> \n";

Add to the $mailheaders variable:

$mailheaders .= "Reply-To: $_POST[sender_email]\n\n";

Add the mail() function:

mail($to, $subject, $msg, $mailheaders);

Close your PHP block:

?>

Measuring Social-Media Optimization

Start Social-Media Optimization to your website


If you’re participating in social media, you’re going
 to want to know how it’s working. But before
you even begin to measure your success, you need
 to know what you’re measuring it against. Define
concrete goals for your efforts. Those might be to
 increase your web-site traffic by a certain amount
each month, to increase conversion values, or some
 other goal. Whatever those goals are, use them
as a guide as you’re planning your social-media
optimization efforts.



You should first have a blog, and then track who
 is reading it. There are many good web analytics
packages that will track what the most popular
 content on your site is. You can probably also see
where those site visitors are coming from and
 how long they’re spending on your page.
This information will help you determine what
 blog entries are most successful and who is
sending the most traffic to your blog, so that you
can capitalize on that.

To find out who is linking to your site
use the following search string, replacing
yourwebsitewith the actual URL of the pages you want to
track: link:http://www.yourwebsitename.com.

Socialmedia networks require constant participation.
 And as with SEO, that means ongoing efforts —
 daily. Integrate your social-media optimization
 strategies into your daily SEO
workflow.

Bhargava and the other social-media experts who
 put this list together are people in the front line
of SEO and SMO social-media optimization every day.
 These guidelines will help you begin youroptimization process.
And if you follow them, you’ll be well on your way to gaining all the value
available from social networks and social media.

Best SEO Practices for a website

Best 35 SEO Practices tips for a website


Review traffic to your site using web server logs and
 third-party.
software      
Understand the content and queries that draw your traffic.

Establish base-line metrics for site traffic, and criteria for success.
Regularly monitor site traffic.
Create content specifically for SEO purposes.
Work to improve PageRank.
Submit to search engines, manually or with a submission tool.
List your site in taxonomies.
List your site in wiki articles.
Request inbound links.
Post comments and pings containing links.
Use syndication for SEO purposes.
Create a bot-friendly site.
Review your site in a text-only web browser.
Add meta information to your site.
Use text rather than graphics when possible.
Add descriptive alt attributes to your images.
Create an easily navigable site.



Keep pages between 100 and 250 words.
Keep keywords dense without stuffing.
Add keywords to <title> and <h1> tags.
Add moderate outbound linking.
Make sure to include cross links.
Deploy web analytics platform Google Analytics or WebTrends.
Avoid dubious SEO practices.
Create a clear and brief campaign plan.
Use AdWords in Conjunction with Core SEO

Use AdWords as an SEO Tool

AdWords as an SEO Tool


As core SEO becomes simply one of the tools used to
 advertise destinations on the Web, it makes sense to
supplement pure SEO with targeted CPCCost per
Clickprograms, such as that provided by Google AdWords.
AdWords should be used as an auxiliary to SEO programs,
 not as the primary focus of an SEO campaign. Attention
 should be paid to distinguishing within AdWords between
 content and search ads.





Search ads, which appear on Google search
 results pages, are generally worth paying more
for per click than content ads, which appear on
web pages enrolled in the Google AdSense program.



As an auxiliary SEO tool, the best approach with AdWords
 is oblique: don't target your primary SEO keywords
 you can rely on SEO for this as much as conceptually
 related topics that might draw visitors who might
otherwise overlook your site.


A benefit of using AdWords as part of your SEO
campaign is that it is very easy to track results because
 you know when your targets get clicked.

seo Keyword Placement tips

Keyword Placement seo tips

 

Keyword Placement

The text on your web page should include the most
 important keywords you have developed in as unforced
 a way as possible. Try to string keywords together to 
make coherent sentences.Not all text on a page is 
equal in importance. First of all, order does count:
 keywords higher up in a given page get more recognition 
from search engines than the same keywords further down a page.
Roughly speaking, besides the body of the page itself 
and in meta information, you should try to place your
 keywords in the following elementspresented roughly in
 order of descending importance:



Title: putting relevant keywords in the HTML title tag for your
 page is probably the most important single thing you can do in terms of SEO

Headers: keyword placement within HTML header styles
, particularly <h1> headers towards the top of a page, is extremely important

Links: use your keywords as much as possible in the
 text that is enclosed by <a href="">...</a> hyperlink tags on your site in outbound and cross bound link. Ask webmasters who provide inbound linking to your site
 to use your keywords whenever possible

Images: include your keywords in the alt attribute of your
 HTML image <img> tags

Text in bold: if there is any reasonable excuse for doing so,
include your keywords within HTML bold <b>... </b> tags

Web Application Concepts

Web Application Concepts-website


Session management, security considerations and
 authentication, and usability form the base of every
 Web application. Web applications aren't possible
 without proper session management. You have to
 find a way to recognize users during multiple page
 requests if you want to associate variables like a
shopping cart with one specific user. And this
 identification had better be secure if you don't want
 to have one user seeing another's credit card information.



 Indeed, special considerations are necessary for improving
 security in your applications. Even if PHP is less prone to
 crackers' attacks than other CGI environments, it's easy
 to write totally exposed applications.

You lose control over the data—as long as the user doesn't return to your site, you can't access the data. And worse, that data may be manipulated when you get it back. Ninety percent of all Web site defacing and breakings come from applications accepting tampered data from the client side and trusting that data. Do not keep data on the client. Do not trust data from the client.

If you use GET/POST, the storage isn't persistent across sessions.

If you rely exclusively on cookies, you have a problem because some users won't accept cookies—they simply disable cookies in their browsers.

The data is hard to maintain because you need to save all data on every page. Each variable needs to be URL-encoded, added to a form as a hidden field or added to the URL, or saved as a cookie. This is difficult for a single variable such as the session ID, let alone dozens of variables!

Thus, the data needs to be stored on the server. Where exactly you store it isn't all that important; it can be in a relational database management system (RDBMS), plaintext file, dBASE file, etc. Because a Web application generally already uses a relational database such as MySQL, this should be the preferred storage medium.

To associate the data with a user, you need a session identity number— a key that ties the user to his data.

php Sessions code


Php Sessions


Sessions are used to help maintain the values of variables
across multiple web pages. This is done by creating a unique
 session ID that is sent to the client browser. The browser
 then sends the unique ID back on each page request and
 PHP uses the ID to fetch the values of all the variables
associated with this session.


The session ID is sent back and forth in a cookie or in the URL.
By default, PHP tries to use cookies, but if the browser has
disabled cookies.








PHP falls back to putting the ID in the URL. The php.ini directives that affect this are:

session.use_cookies
When on, PHP will try to use cookies

session.use_trans_sid
When on, PHP will add the ID to URLs if cookies are not used

The trans_sid code in PHP is rather interesting. It actually parses the entire HTML file and modifies/mangles every link and form to add the session ID. The url_rewriter.tags php.ini directive can change how the various elements are mangled.

Writing an application that uses sessions is not hard. You start a session using session_start( ), then register the variables you wish to associate with that session. For example:

<?php
  session_start( );
  session_register('foo');
  session_register('bar');

  $foo = "Hello";
  $bar = "World";
?>

If you put the previous example in a file named page1.php and load it in your browser, it sends you a cookie and stores the values of $foo and $bar on the server. If you then load this page2.php page:

<?php
  session_start( );
  echo "foo = $_SESSION[foo]<br />";
  echo "bar = $_SESSION[bar]<br />";
?>
You should see the values of $foo and $bar set in page1.php. Note the use of the $_SESSION superglobal. If you have register_globals on, you would be able to access these as $foo and $bar directly.

You can add complex variables such as arrays and objects to sessions as well. The one caveat with putting an object in a session is that you must load the class definition for that object before you call session_start( ).

A common error people make when using sessions is that they tend to use it as a replacement for authentication -- or sometimes as an add-on to authentication. Authenticating a user once as he first enters your site and then using a session ID to identify that user throughout the rest of the site without further authentication can lead to a lot of problems if another person is somehow able to get the session ID. There are a number of ways to get the session ID:

If you are not using SSL, session IDs may be sniffed

If you don't have proper entropy in your session IDs, they may be guessed

If you are using URL-based session IDs, they may end up in proxy logs

If you are using URL-based session IDs, they may end up bookmarked on publicly-accessible computers

All Operators Of PHP

 

All PHP Operators

 An expression is the basic building block of the language.
Anything with a value can be thought of as an expression. Examples include:

5
5+5
$a
$a==5
sqrt(9)
By combining many of these basic expressions, you can build larger, more complex expressions.

Note that the echo statement we've used in numerous examples cannot be part of a complex expression because it does not have a return value. The print statement, on the other hand, can be used as part of complex expression -- it does have a return value. In all other respects, echo and print are identical: they output data.




Expressions are combined and manipulated using operators. The following table lists the operators from highest to lowest precedence; the second column (A) shows the operators' associativity. These operators should be familiar to you if you have any C, Java, or Perl experience.

Operators
A
!, ~, ++, --, @, (the casting operators)
Right
*, /, %
Left
+, -, .
Left
<<, >>
Left
<, <=, >=, >
Nonassociative
==, !=, ===, !==
Nonassociative
&
Left
^
Left
|
Left
&&
Left
||
Left
? : (conditional operator)
Left
=, +=, -=, *=, /=, %=, ^=, .=, &=, |=, <<=, >>=
Left
AND
Left
XOR
Left
OR
Left

Variables in PHP


Variables in PHP

Variables are used for storing a values, like text strings, numbers or arrays.
When a variable is set it can be used over and over again in your script
All variables in PHP start with a $ sign symbol.
The correct way of setting a variable in PHP:



<?php
$txp = "test";
$no = 18;
?>

PHP here are  three different variable scopes:

    local
    global
    static

Variable Naming Rules

  • A variable name must start with a letter or an underscore "_"
  • A variable name can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ )
  • A variable name should not contain spaces. If a variable name is more than one word, it should be separated with underscore ($my_string), or with capitalization ($myString)






PHP Array Introduction


Function Description PHP


 Testing Array and sizeof( )
<?php
$fixture = Array( );
// $fixture is expected to be empty.

$fixture[] = "element";
// $fixture is expected to contain one element.
?>


A really simple way to check whether we are getting the results we expect is to print the result of sizeof( ) before and after adding the element

array() Creates an array 
array_change_key_case() Returns an array with all keys in lowercase or uppercase
array_chunk() Splits an array into chunks of arrays 
array_combine() Creates an array by using one array for keys and another for its values 
array_count_values() Returns an array with the number of occurrences for each value
array_diff() Compares array values, and returns the differences
array_diff_assoc() Compares array keys and values, and returns the differences 
array_diff_key() Compares array keys, and returns the differences 
array_diff_uassoc() Compares array keys and values, with an additional user-made function check, and returns the differences 
array_diff_ukey() Compares array keys, with an additional user-made function check, and returns the differences 
array_fill() Fills an array with values 
array_filter() Filters elements of an array using a user-made function 
array_flip() Exchanges all keys with their associated values in an array 
array_intersect() Compares array values, and returns the matches 
array_intersect_assoc() Compares array keys and values, and returns the matches 
array_intersect_key() Compares array keys, and returns the matches 
array_intersect_uassoc() Compares array keys and values, with an additional user-made function check, and returns the matches 
array_intersect_ukey() Compares array keys, with an additional user-made function check, and returns the matches 
array_key_exists() Checks if the specified key exists in the array 
array_keys() Returns all the keys of an array 
array_map() Sends each value of an array to a user-made function, which returns new values 4
array_merge() Merges one or more arrays into one array 
array_merge_recursive() Merges one or more arrays into one array 
array_multisort() Sorts multiple or multi-dimensional arrays 
array_pad() Inserts a specified number of items, with a specified value, to an array 
array_pop() Deletes the last element of an array 
array_product() Calculates the product of the values in an array 
array_push() Inserts one or more elements to the end of an array 
array_rand() Returns one or more random keys from an array 
array_reduce() Returns an array as a string, using a user-defined function 
array_reverse() Returns an array in the reverse order 
array_search() Searches an array for a given value and returns the key 
array_shift() Removes the first element from an array, and returns the value of the removed element 
array_slice() Returns selected parts of an array 
array_splice() Removes and replaces specified elements of an array 
array_sum() Returns the sum of the values in an array 
array_udiff() Compares array values in a user-made function and returns an array 
array_udiff_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 
array_udiff_uassoc() Compares array keys and array values in user-made functions, and returns an array 
array_uintersect() Compares array values in a user-made function and returns an array 
array_uintersect_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 
array_uintersect_uassoc() Compares array keys and array values in user-made functions, and returns an array 
array_unique() Removes duplicate values from an array 
array_unshift() Adds one or more elements to the beginning of an array 
array_values() Returns all the values of an array 
array_walk() Applies a user function to every member of an array 
array_walk_recursive() Applies a user function recursively to every member of an array 
arsort() Sorts an array in reverse order and maintain index association 
asort() Sorts an array and maintain index association 
compact() Create array containing variables and their values
count() Counts elements in an array, or properties in an object 
current() Returns the current element in an array 
each() Returns the current key and value pair from an array 
end() Sets the internal pointer of an array to its last element 
extract() Imports variables into the current symbol table from an array 
in_array() Checks if a specified value exists in an array
key() Fetches a key from an array
krsort() Sorts an array by key in reverse order
ksort() Sorts an array by key 
list() Assigns variables as if they were an array 
natcasesort() Sorts an array using a case insensitive "natural order" algorithm 

natsort() Sorts an array using a "natural order" algorithm 
next() Advance the internal array pointer of an array 
pos() Alias of current() 
prev() Rewinds the internal array pointer 
range() Creates an array containing a range of elements 
reset() Sets the internal pointer of an array to its first element
rsort() Sorts an array in reverse order
shuffle() Shuffles an array 
sizeof() Alias of count()
sort() Sorts an array 
uasort() Sorts an array with a user-defined function and maintain index association
uksort() Sorts an array by keys using a user-defined function
usort() Sorts an array by values using a user-defined function