Archive for the 'php' Category

PHP $_GET and $_POST at php form

PHP $_GET
The $_GET variable is used to collect values from a form with method=”get”
Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser’s address bar)
<html>
<body>
<form action=”welcome.php” method=”get“>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>
</body>
</html>
When we input Johnson at name and 30 […]

Function Hide variable / Change Variable

This function for change some variable into other variable.
Example : we want to change phone number : 6281234123457 into 628123412XXXX
Example :
<?php
function hide($rp)
{
$hidee = “”;
$p = strlen($rp);
$hidee = “.” . substr($rp,-4) . $hidee;
$l = strlen($rp) - 4;
$rp = substr($rp,0,$l);
$p = strlen($rp);
$hidee = $rp . XXXX;
return $hidee;
}
$phone =”6281234123457″;
$phonehide = hide($phone);
echo”$phonehide”;
?>
Result fot this :
628123412XXXX
Hope you like this function

PHP Forms and User Input

The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.
Form example :
<html>
<body>
<form action=”welcome.php” method=”post”>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>
</body>
</html>
The example HTML page above contains two input fields and a […]

another most use

Another most use at php
For collect data from database
<?
$result = mysql_query( “SELECT * FROM reseller” ) or error( mysql_error() );
$data = mysql_fetch_array( $result );
$totalMember = mysql_num_rows( $result );
?>
if at database has 14 input,
<?= $totalMember ?> will output 14
<?= $totalMember ?> same with <? echo”$totalMember”; ?>

Query update database

uery update is used for edit value in database
This is value at database reseller that we have insert first.

field username with value johnson
field passwd with value johnson$32#
field name with value Johnson Gunawan
field email with value Johnson@yahoo.com

After insert data to database, if want to edit/change value we can use :
mysql_query( ”
update database_name
set […]