Showing posts with label PHP with MYSQL. Show all posts
Showing posts with label PHP with MYSQL. Show all posts

Monday, 17 September 2012

Local UTF-8 Pages Coming Out as Plain Text

In this case the Content-Type header is relevant and you should look for a header that looks like: 

Content-Type: text/html; charset=UTF-8


This: 

<meta charset="UTF-8"> 

locally, is getting the file opened as plain text. Page info gives "text/plain" as Type. 

When I add either: 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 

and in fact just 

<meta http-equiv="Content-Type" charset=utf-8"> 

it looks fine locally. FF Page Info then gives "text/html" as Type. 

I altered the default character encoding in FF and it made no difference unfortunately. 


Lowercase Words To Uppercase Words

Hello Friends in this tutorials how to lowercase words will be replaced with upper/lowercase words to the use of DataBase.you to replace words in string with a tag where url is from database.  

$nodecontent="this is test NIke CaLLaway page redirect blah blah"

$query = "SELECT * FROM wordlist";
$rst = mysql_query($query, $con);
while($row = mysql_fetch_assoc($rst)) {
$nodecontent= str_ireplace(" ".$row['link']." ", " <a href='". $row['url'] ."'>". $row['link'] ."</a> ");

}


This *would* (in your example) output: 

this is test <a href="www.nike.com">nike</a> <a href="www.callaway.com">callaway</a> page redirect blah blah" 

instead of 

this is test <a href="www.nike.com">NIke</a> <a href="www.callaway.com">CaLLaway</a> page redirect blah blah" 


Note the lowercase words will be replaced with the upper/lowercase version that is in the DB.
 

How To Use CSS and HTML in the Same Statement


To use both CSS and HTML in the same statement, but it is considered best to push as much of the formatting as possible into CSS, and the <font> tag is one that people say to avoid. In your example, you can do all the styling with CSS: 

<h1 style="text-align:center; font-family:arial,sans-serif; font-size:large;">Text Here</h1> 

I hope I got that mostly right. There are various ways to specify font size. I chose one that might not be the exact equivalent of size=5. 

Alternatively, you can put a separate style declaration in your page, or even in a separate .css file, which makes it much easier to make site-wide changes. This would style all h1 tags: 

h1 
{ 
text-align:center; 
font-family:arial,sans-serif; 
font-size:large; 
} 

Friday, 14 September 2012

Simply Create Drop Down Menu

     Dropdown Menu

A Dropdown list is a combination of items in a list. In the dropdown list menu only the title is visible but not the contents. The contents are shown only when the user activates it by a small arrow. The user may select an item from the menu by dragging the mouse from the menu title or by clicking the title and then clicking the item. The dropdown list box is read-only.


We can say a drop down list is a box containing a list of multiple items. A drop-down list is a list in which the selected item is always visible, and the others are visible on demand by clicking a drop-down button.

The main advantages of a drop down list is to save space because the number of views is not limited by space.

There are two types of dropdown lists, which are as follows:
  • Static dropdown list
  • Dynamic dropdown list
Source Code:  Download

Simply image upload in PHP with MYSQL


Hi I have read many forums and websites that tell you how to upload an image to a server and I have managed to get this working, I can upload a file to a my server but storing the file name does work on the following example I found and I also need to create a form that allows more data to be entered to the database. I am stuck with this as a have done much php before. I have come to the end of trying different websites tutorals with no much success could anyone please help me! I need it done for a project im doing. 

If you want to use the image upload in your websites then you click the download option and enjoy is this coding.........

Source Code:   Download

Classes Use in PHP


Class definition:

include('snapshot.class.php');
$myimage = new ImageSnapshot;
$myimage->ImageField = $_FILES['userfile'];
$myimage->Width = 100;
$myimage->Height = 100;
$myimage->Resize = true;
$myimage->ResizeScale = 50;
$myimage->Position = 'center';
$myimage->Compression = 80;

If you want to save the altered image as a file:

if ($myimage->SaveImageAs('temp.jpg')) {
echo '<img src="temp.jpg" border="0" alt="test" />';
} else {
echo $myimage->Err;
}

OR if you want to get the contents of the saved image as a variable:

if ($myimage->ProcessImage() !== false) {
$img = $myimage->GetImageContents();
} else {
echo $myimage->Err;
}


Imagefield

This variable holds the exact array of the $_FILES field that you specify. If the file is not a valid image (jpg, gif, png) the class will return an error when SaveImageAs or ProcessImage is called.

Wednesday, 12 September 2012

PHP ( Tutorial III )


What is Session Handling in PHP

There are many ways that session handling can be used to provide a dynamic and non-static experience for the end user. session can be used for providing a more personal experience for the end user by keeping track of them as they roam through a site providing concept that is more trailored to their likes and dislikes.Session can also be used to make a valid usernamr and password can gain access to  apart of any sites, or in the case of any online store.

MYSQL is a perfect companion to session handling to help with the process of storing and retrieving the data that gives extra life to the session handling capabilites........

PHP ( Tutorial II )


PHP Secure

Having connection information stored in a plain readable fashion can be disconcerting to many new web developers; however, with the right security steps, this can be less of a concern. The following are some steps that should be addressed to make sure that the informaiton is Kept secure:
 

 Operatin System Rights- Almost every operating system provides a mean to limit access to files
by end users in one fashion or another.

Remote Connections- In the example up to the point, the connection have been made to localhost;
however, there are setups in which a connection is made to an external server that requires sending information throught an interconnect of some sort.

PHP ( Tutorials I )


PHP Authenticate

Simple coding of securing page in PHP.

If you want to login in the permission base,mean same page open in the many password then to use a following Code.This code Save in PHP and run to the localhost server.The below code has three username and password combinations. A function has also been added that will be used to check if a user has been logged in and will be used to authenticate many user on same page to login......

This code Save the name of  password.php and run the localhost server. 

<?php

$v=sha1('pass1');

Echo $v;

?>


Shown below code save a text file and you want to create a many password in the same method but  you  to change the value of pass1 every time and the output is different -2....

output is:9e5ca6b0ffb417997ffb844c76f9c24bbc20fe88


Then to use a following code and save the password_login.php......

<?php

$authorized_user=FALSE;

if (isset($_SERVER['PHP_AUTH_USER']) && isset ($_SERVER['PHP_AUTH_PW']))

{

$autharray=file("http://URL.txt");

foreach($autharray as $row) {

list ($user,$pswd)=explode(":",$row);

$pswd=trim($pswd);

if (($_SERVER['PHP_AUTH_USER']==$user) &&

(sha1($_SERVER['PHP_AUTH_PW'])==$pswd))  {

$authorized_user=TRUE;

break;

}   

}

}

if (!$authorized_user)  {

header('www-authenticate:basic realm="Photo album" ');

header('Http/1.0  401 unauthorized');

print "invalid user name and password ! ";

exit;

}

else

echo "Welcome <br>";

?>